diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java index b5bf5ab9c..9718bb697 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java @@ -5,6 +5,7 @@ import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.HapticFeedbackConstants; import android.view.View; @@ -67,18 +68,24 @@ public final class TouchscreenControllerButtonView extends View { protected void onDraw(Canvas canvas) { super.onDraw(canvas); - final int paddingLeft = getPaddingLeft(); - final int paddingTop = getPaddingTop(); - final int paddingRight = getPaddingRight(); - final int paddingBottom = getPaddingBottom(); - final int contentWidth = getWidth() - paddingLeft - paddingRight; - final int contentHeight = getHeight() - paddingTop - paddingBottom; + int leftBounds = 0; + int rightBounds = leftBounds + getWidth(); + int topBounds = 0; + int bottomBounds = topBounds + getHeight(); + + if (mPressed) { + final int expandSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + 10.0f, getResources().getDisplayMetrics()); + leftBounds -= expandSize; + rightBounds += expandSize; + topBounds -= expandSize; + bottomBounds += expandSize; + } // Draw the example drawable on top of the text. Drawable drawable = mPressed ? mPressedDrawable : mUnpressedDrawable; if (drawable != null) { - drawable.setBounds(paddingLeft, paddingTop, - paddingLeft + contentWidth, paddingTop + contentHeight); + drawable.setBounds(leftBounds, topBounds, rightBounds, bottomBounds); drawable.draw(canvas); } } diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerDPadView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerDPadView.java index 28cc6f983..797abb267 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerDPadView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerDPadView.java @@ -2,9 +2,11 @@ package com.github.stenzek.duckstation; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; +import android.util.TypedValue; import android.view.View; public final class TouchscreenControllerDPadView extends View { @@ -122,10 +124,19 @@ public final class TouchscreenControllerDPadView extends View { } private void drawDirection(int direction, int subX, int subY, Canvas canvas, int buttonWidth, int buttonHeight) { - final int leftBounds = subX * buttonWidth; - final int rightBounds = leftBounds + buttonWidth; - final int topBounds = subY * buttonHeight; - final int bottomBounds = topBounds + buttonHeight; + int leftBounds = subX * buttonWidth; + int rightBounds = leftBounds + buttonWidth; + int topBounds = subY * buttonHeight; + int bottomBounds = topBounds + buttonHeight; + + if (mDirectionStates[direction]) { + final int expandSize = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + 10.0f, getResources().getDisplayMetrics()); + leftBounds -= expandSize; + rightBounds += expandSize; + topBounds -= expandSize; + bottomBounds += expandSize; + } final Drawable drawable = mDirectionStates[direction] ? mPressedDrawables[direction] : mUnpressedDrawables[direction]; drawable.setBounds(leftBounds, topBounds, rightBounds, bottomBounds); diff --git a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml index 39fd2b168..12c999580 100644 --- a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml +++ b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml @@ -5,7 +5,8 @@ android:id="@+id/constraintLayout" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:orientation="vertical" + android:clipChildren="false"> + android:orientation="vertical" + android:clipChildren="false"> + android:orientation="vertical" + android:clipChildren="false"> + android:orientation="vertical" + android:clipChildren="false">