我想补充一个必填字段用红色星号xamarin Android.Having这方面有任何想法textinputlayout。我试着在谷歌找到,但没有得到任何解决方案。
要asterics添加到您的TextView
你需要使用SpannableStringBuilder
。请参阅此处显示的代码:
var txt = FindViewById<EditText>(Resource.Id.textInputEditText1);
TextView text = (TextView)FindViewById(Resource.Id.textView1);
string simple = "CREATE PASSWORD";
string colored = "*";
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.Append(simple);
int start = builder.Length();
builder.Append(colored);
int end = builder.Length();
builder.SetSpan(new ForegroundColorSpan(Color.Red), start, end,SpanTypes.ExclusiveExclusive);
text.SetText(builder, TextView.BufferType.Normal);
axml代码
<TextView
android:text="Create Password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1" />
<EditText
android:layout_width="match_parent"
android:text="123456767888"
android:layout_height="wrap_content"
android:id="@+id/textInputEditText1"
android:password="true" />
输出截图