简体   繁体   English

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

[英]Unknown Black Border around Android Buttons on Click

After specifying a custom style for some buttons that I am using for an Android app, I noticed that a mysterious black border appearing around the button when clicked. 在为我用于Android应用程序的某些按钮指定了自定义样式后,我注意到单击该按钮周围会出现一个神秘的黑色边框。 I have tried overriding the border in my style, but nothing seems to work. 我尝试以我的样式覆盖边界,但是似乎没有任何效果。 How can I get rid of it? 我该如何摆脱呢?

orange_button.xml 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 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 追问

追问

EDIT: try adding this in your styles.xml: 编辑:尝试将其添加到您的styles.xml中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM