2014-03-26 153 views
1

创建一个按钮,我试图去模仿一个按钮是这样的:安卓:有边框底部

enter image description here

有一个灰色的背景与其他灰色底部边框。

我不知道如何添加这个美好的底部边框。这是我现在的结果:

enter image description here

这里是我的按钮的代码:

<Button 
     android:id="@+id/button_consulter_original" 
     style="?android:attr/borderlessButtonStyle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dp" 
     android:layout_marginLeft="50dp" 
     android:layout_marginRight="50dp" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/button_custom" 
     android:text="@string/detail_article_view_consulter_sur_web" 
     android:textColor="@color/blanc" /> 

和button_custom.xml的代码:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@color/bleuactionbarFonce" 
      android:state_pressed="true" /> 
    <item android:drawable="@color/bleuHome" 
      android:state_focused="true" /> 
    <item android:drawable="@color/gray" /> 
</selector> 

回答

1

添加下面这个观点您Button

<View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@android:color/darker_gray" /> 

这会添加边框效果,