2016-11-04 93 views
0

如何将编辑文本中的underbar,先前的underbar自动传入,但现在我现在找不到它。我必须使用android:background属性添加它,并绘制一个线条形状,但这也不工作,因为笔画出现在文本的中心。所以,我怎么可以得到下吧在编辑文本中放置underbar android

编辑文本代码

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/line2" 
     android:hint="hhkfnvkslnbkfnbkfnbknbdkbnlbkn" 
     android:paddingBottom="5dp" 
     android:paddingTop="5dp" 
     android:textColorHint="@color/colorAccent" /> 

行程

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> 
    <stroke android:width="1dp" android:color="#0000FF"/> 
    <size android:height="100dp" /> 
</shape> 
+0

请在这里发布您的输出图像。 – Bethan

回答

0

刚刚创建的EditText下面一个观点:

<EditText 
    android:id="@+id/underbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/line2" 
    android:hint="hhkfnvkslnbkfnbkfnbknbdkbnlbkn" 
    android:paddingBottom="5dp" 
    android:paddingTop="5dp" 
    android:textColorHint="@color/colorAccent" /> 

<View 
    android:id="@+id/underbar" 
    style="@style/EditTextLine" 
    android:layout_below="@+id/underbar"/> 

而且在你的styles.xml

<style name="EditTextLine"> 
    <item name="android:layout_height">1dp</item> 
    <item name="android:layout_width">match_parent</item> 
    <item name="android:background">@color/colorAccent</item> 
</style> 

确保的EditText和查看被包裹在一个RelativeLayout。您可以在每个EditText下重新使用相同的underbar样式。