2017-10-29 18 views
-1

異なる外観のテキストビューを作成したい(正確にのみ下線のみ)誰かがどのようにこれを達成できるかを教えてもらえますか?私はxamarin androidでやっています。動的下線付き文字

underlined letters

答えて

2

あなたは線を引くshapeを使用することができます。

1.shape_line.xml

そして、あなたはandroid:widthandroid:heightを変更することができます。

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="@android:color/white" /> 
    <padding android:top="10dp" /> 
    <size 
     android:width="60dp" 
     android:height="10dp" /> 
</shape> 

2.このように使用します。あなたがEditTextを使用3.Ifは、それが底に色を持っています.Otherwise

editText = (EditText) findViewById(R.id.et); 
editText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, R.drawable.shape_line); 

、あなたはandroid:background="@null"を設定する必要があります。

<EditText 
    android:id="@+id/et" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" 
    android:background="@null" 
    android:gravity="center" 
    android:text="N" 
    android:textColor="@android:color/white" /> 

出力

enter image description here

+0

私は今それをしようとすることはできませんが、私は間違いなくそれをしようとします。ありがとう! – xDarC

+0

あなたに幸運。 – KeLiuyue

+0

それは働いた。ありがとうございました! – xDarC

関連する問題