2010-12-10 42 views
4

嗨 在我的應用程序中包含一個按鈕,目前我使用xml爲改變背景定製,它在2.1中正常工作,但是當達到2.2時,按鈕很難打到,怎麼可以我解決了這個問題?下面Android按鈕很難在2.2中打出

<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" 
/> 

回答

10

我的按鈕的XML代碼給出如果你的按鈕是小,很難擊中使用Inset Drawable。您可以設置要顯示的繪圖和左側,頂部,右側和底部的插圖。插圖就像某種保證金,但可點擊。

下面是一個例子。

<?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"/> 

那將使你的按鈕是10dp高在每邊爲觸摸事件。你的按鈕的外觀不會改變。

現在在您的佈局中,您不會將原始可繪製設置爲Button的背景,而是將新的Inset Drawable