单击Android按钮周围的未知黑色边框

时间:2014-08-05 18:34:04

标签: android android-button android-styles

为我用于Android应用程序的某些按钮指定自定义样式后,我注意到单击按钮时出现了一个神秘的黑色边框。我尝试过以我的风格覆盖边界,但似乎没有任何效果。我怎么能摆脱它?

orange_button.xml

<item  android:state_pressed="true" android:drawable="@color/OrangePastel"/>
<item  android:state_pressed="false" android:drawable="@color/OrangePastel"/>
<item  android:state_focused="true" android:drawable="@color/GreenPastel"/>
<item  android:state_focused="false" android:drawable="@color/GreyPastel"/>
<item  android:state_selected="true" android:drawable="@color/YellowPastel"/>
<item  android:state_selected="true" android:drawable="@color/PurplePastel"/>
<item  android:state_window_focused="true" android:drawable="@color/LavenderPastel"/>
<item  android:state_window_focused="false" android:drawable="@color/WhitePastel"/>
<item  android:state_checkable="false" android:drawable="@color/RedPastel"/>
<item  android:state_checkable="true" android:drawable="@color/DarkGreenPastel"/>
<item android:state_hovered="true"
    android:drawable="@color/OrangePastel"/>
<item  android:state_checked="false"
android:drawable="@color/OrangePastel"/>
<item  android:state_checked="true" android:drawable="@color/OrangePastel"/>

activity_button_test.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="ButtonTestActivity">

    <Button
        android:id="@+id/testButton2"
        android:text="@string/hello_world"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/orange_button"/>


</LinearLayout>

未按下

Unpressed

Pressed

1 个答案:

答案 0 :(得分:1)

编辑:尝试在styles.xml中添加它:

<resources>
  <style name="AppTheme" parent="android:Theme.Holo.Light">
    <item name="android:buttonStyle">android:borderlessButtonStyle</item>
  </style>
</resources>