英文:
how can I remove button bottom border
问题
I want to use custom background on android button without any border and with radius only on top of the button and I make the drawable like that but the problem I got a gray line in the bottom of the button how I can remove it I already using style="@android:style/Widget.Holo.Button.Borderless" but it didn't make anything
我想在Android按钮上使用自定义背景,没有任何边框,只在按钮顶部使用半径。我已经创建了这样的可绘制对象,但问题是我得到了按钮底部的灰色线条,我如何移除它?我已经使用style="@android:style/Widget.Holo.Button.Borderless",但它没有产生任何效果。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/turquoise" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
<solid android:color="@color/white" />
<size android:height="60dp" />
</shape>
</item>
</layer-list>
and here is the button used in the layout
以下是布局中使用的按钮:
<Button
android:id="@+id/btn_bg"
style="@android:style/Widget.Holo.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="60dp"
android:clickable="false"
android:background="@drawable/custom_bg_white"
android:textSize="14sp"
android:visibility="visible" />
<details>
<summary>英文:</summary>
[![enter image description here][1]][1]
I want to use custom background on android button without any border and with radius only on top of the button and I make the drawable like that but the problem I got a gray line in the bottom of the button how I can remove it I already using style="@android:style/Widget.Holo.Button.Borderless" but it didn't make anything
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/turquoise" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
<solid android:color="@color/white" />
<size android:height="60dp" />
</shape>
</item>
</layer-list>
and here is the button used in the layout
<Button
android:id="@+id/btn_bg"
style="@android:style/Widget.Holo.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="60dp"
android:clickable="false"
android:background="@drawable/custom_bg_white"
android:textSize="14sp"
android:visibility="visible" />
[1]: https://i.stack.imgur.com/9ldcS.png
</details>
# 答案1
**得分**: 1
这条灰线不是边框,而是按钮样式产生的高度。如果不想要它,请设置`android:elevation=0dp`并设置`android:stateListAnimator="@null"`。
<details>
<summary>英文:</summary>
this gray line is not border it's the elevation that is made by the button style if you don't want it set `android:elevation=0dp` and set ` android:stateListAnimator="@null"`
</details>
# 答案2
**得分**: 0
Replace your drawable file with below code and check
```xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
<solid android:color="@color/white" />
<size android:height="60dp" />
</shape>
</item>
</layer-list>
or Share your full xml layout file code
英文:
Replace your drawable file with below code and check
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="14dp"
android:topRightRadius="14dp" />
<solid android:color="@color/white" />
<size android:height="60dp" />
</shape>
</item>
</layer-list>
or Share your full xml layout file code
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论