0

我在其他颜色按钮上制作了可点击效果但是如何为白色按钮生成可点击效果

<Button
            android:id="@+id/featured_listing_button_id"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="-7dp"
            android:background="@drawable/botton_account_middle_white"
            android:text="Featured Listing" />

我试过的 :: 我把按钮设为白色,还有一些其他的属性

但是现在没有点击效果!

botton_account_middle_white.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="#FFFFFF" />

    <stroke
        android:width="3px"
        android:color="#000000" />

    <corners android:radius="3dp" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />



    <corners
        android:bottomLeftRadius="0dp"
        android:bottomRightRadius="0dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp" />

</shape>

如何赋予按钮可点击的效果!... 白色按钮

4

2 回答 2

0

您应该使用选择器突出显示按钮。

button_selector.xml

 <selector xmlns:android="http://schemas.android.com/apk/res/android" >
         <item 
     android:state_selected="false"
        android:state_pressed="false" 
        android:color="@color/normal" />
    <item android:state_pressed="true" 
        android:color="@color/pressed" />
    <item android:state_selected="true"
     android:state_pressed="false" 
        android:color="@color/pressed" />
</selector>

像这样使用它

<Button
            android:id="@+id/featured_listing_button_id"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="-7dp"
            android:background="@drawable/button_selector"
            android:text="Featured Listing" />
于 2013-10-25T13:34:52.850 回答
0
<?xml version="1.0" encoding="utf-8"?> 
  <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
      <item android:state_focused="true" android:state_pressed="true" 
            android:drawable="@drawable/bgalt" /> 
      <item android:state_focused="false" android:state_pressed="true" 
            android:drawable="@drawable/bgalt" /> 
      <item android:drawable="@drawable/bgnorm" /> 
  </selector>
<Button
  android:id="@+id/mybutton"
  android:background="@drawable/selector" />
于 2013-10-25T13:37:44.443 回答