Reputation: 159
I got an ImageButton which's clickable area needs to be bigger than just the image itself, I do, however, want to constraint that button on the left to a text box... I've looked through similar questions but couldn't find an answer that helps. This is the code rn:
<ImageButton
android:id="@+id/skipButton"
android:layout_width="42dp"
android:layout_height="40dp"
android:background="@null"
android:onClick="onSkipButtonPressed"
android:padding="0px"
android:scaleType="fitCenter"
android:scaleX="0.5"
android:scaleY="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/hintTextView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.989"
app:srcCompat="@drawable/skip_button_selector" />
And here's an image of what the contraints look like...
I hope this is enough info to help with this issue. I'm rather lost with it tbh. Thank you very much!
Upvotes: 0
Views: 83
Reputation: 1060
Just increase the padding and size of your image
<ImageButton
android:id="@+id/skipButton"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@null"
android:onClick="onSkipButtonPressed"
android:padding="10dp"
android:scaleType="fitCenter"
android:scaleX="0.5"
android:scaleY="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/hintTextView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.989"
app:srcCompat="@drawable/skip_button_selector/>
also you can use paddingEnd and paddingBottom attributes it will not change position of your image but increase the area
<ImageButton
android:id="@+id/skipButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@null"
android:onClick="onSkipButtonPressed"
android:paddingEnd="10dp"
android:paddingBottom="10dp"
android:scaleType="fitCenter"
android:scaleX="0.5"
android:scaleY="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/hintTextView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.989"
app:srcCompat="@drawable/skip_button_selector/>
Upvotes: 1