2017-09-26 90 views
0

我在我的佈局中有一個TextInputLayout,我想在它的提示中使用html標記或spannable,但它不起作用。是否可以在TextInputLayout提示中使用html標籤或spannable?

我搜索谷歌的所有鏈接,但結果是「現在是不可能的,也許在下一個版本和更新是可能的」。

是否可以自定義TextInputLayout視圖來接受提示中的html標籤?我該怎麼做?

+0

添加一些代碼將是一個不錯的主意。 – iMDroid

+0

@iMDroid感謝您的幫助 – hamed

+0

@iMDroid去年提出了一個類似於我的問題。你有沒有找到解決方案? – hamed

回答

3

添加以下代碼在佈局XML文件TextInputLayout:

<android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="@dimen/activity_horizontal_margin" 
     app:hintAnimationEnabled="false"> 

     <android.support.design.widget.TextInputEditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
       android:hint="@string/enter_message" /> 

    </android.support.design.widget.TextInputLayout> 

在string.xml文件中添加以下代碼:

<string name="enter_message">Enter Message<font fgcolor="red">*</font></string> 
+0

它沒有工作。請仔細閱讀問題 – hamed

+0

您無法使用XML設置HTML數據。它必須在代碼中完成,否則數據不會生效 – Zoe

+0

@hamed是否可以爲相同的代碼添加代碼?這將有助於理解.... –

相關問題