2017-03-05 9 views
0

EditTextのための永久的なアンダーラインを作成するにはどうすればいいですか? 別のトピックで回答が見つかりませんでした。 私はそのような何かを達成したいと思います: enter image description hereアンダーライン編集テキスト

+0

これを試してみましたか:http://stackoverflow.com/a/37101446/2632867 – Alvi

答えて

0

あなたはこのようstyle.xmlであなたのEditTextのためのカスタムスタイルを使用することができます -

<!-- Edit text --> 
    <style name="editTextStyle" parent="Theme.AppCompat.Light.NoActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="android:textSize">@dimen/auth_text_paragraph_little</item> 
     <item name="android:layout_gravity">left</item> 
     <item name="android:focusable">true</item> 
     <item name="colorControlNormal">@color/editUnderLine</item> 
     <item name="colorControlActivated">@color/colorAccent</item> 
     <item name="colorControlHighlight">@color/colorAccent</item> 
     <item name="android:textColorHint">@color/hint</item> 
    </style> 

@color/editUnderLineはあなたとしてcolor.xmlファイルから使用する色の名前です。以下のようなstring.xmlファイルとdimen.xmlファイルとして

とあなたのXMLにこのカスタムスタイルを使用してレイアウト -

    <EditText 
         android:id="@+id/edt_phone_number" 
         style="@style/editTextStyle" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="@dimen/auth_margin_half" 
         android:padding="@dimen/auth_margin_half_plus" 
         android:fontFamily="@string/auth_font_family_regular" 
         android:hint="@string/auth_mobile_number" 
         android:inputType="phone"/> 
関連する問題