A
A
Alexey Medvedev2015-10-22 22:46:53
Java
Alexey Medvedev, 2015-10-22 22:46:53

How to stretch the click area of ​​a button, but not stretch the background?

How to do it like in the diagram below?
2f55d8a7a81d46e1916e4d71845d3931.png
There is a big button, half the screen. The click area should be half the screen. The code:

<Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/button_play"
            android:id="@+id/button"
            android:onClick="start"/>

But the background image is stretched to full screen (it seems to be clear why). I can't change the button parameters for 'wrap_content', the click area is reduced to the size of the image.
I'm sure the solution will turn out to be quite simple, but until you know it, and don't know how to google it, it seems complicated. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Medvedev, 2015-10-23
@RockBearLTD

I remade the Button into an ImageButton, made the picture the android:src attribute, and made an empty transparent picture on the background.

B
bracadabra, 2016-07-14
@bracadabra

For such cases, TouchDelegate is used .

T
Tiberal, 2015-10-23
@Tiberal

set the android:padding attribute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question