Android button hard to get into 2.2

Hi, there is a button in my application, I am currently configured with xml to change the background, and it works fine in 2.1, but when I get to 2.2, the button is hard to hit, how can I solve the problem?

x button code below

<Button android:id ="@+id/Button_Continue1" android:background="@drawable/continue_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" /> 
+4
source share
1 answer

If your button is small and hard to hit, use Inset Drawable . You set the dropdown you want to display and the insert on the left, top, right, and bottom. The insert is similar to some margin, but is clickable.

Here is an example.

 <?xml version="1.0" encoding="UTF-8"?> <inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/your_drawable" android:insetTop="10dp" android:insetRight="10dp" android:insetBottom="10dp" android:insetLeft="10dp"/> 

This will cause your button to be 10dp higher on each side for touch events. The appearance of your button will not change.

Now in your layout you no longer set the source drawing as the Button background, but the new Inset Drawable .

+10
source

All Articles