Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android button hard to hit in 2.2

Tags:

android

Hi in my app contain a Button ,currently i customized using xml for changing the background and it work fine in 2.1 but when am reach to 2.2 ,The button is hard to hit ,how can i solve the issue?

my button xml code given 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"
 /> 
like image 814
Bytecode Avatar asked Dec 29 '22 04:12

Bytecode


1 Answers

If your button is small and hard to hit use an Inset Drawable. You set the drawable you want to have displayed and the inset on the left, top, right and bottom. The inset is like some kind of margin but 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"/>

That will make your button to be 10dp taller on every side for touch events. The look of your button will not change.

Now in your layout you don't set your original drawable as the Button's background anymore but the new Inset Drawable.

like image 83
Octavian A. Damiean Avatar answered Jan 11 '23 08:01

Octavian A. Damiean