我想补充一个必填字段与xamarin Android的红色星号textinputlayout

问题描述 投票:0回答:1

我想补充一个必填字段用红色星号xamarin Android.Having这方面有任何想法textinputlayout。我试着在谷歌找到,但没有得到任何解决方案。

http://prntscr.com/mfjv7k

android xamarin xamarin.android
1个回答
0
投票

要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" />

输出截图

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.