Android 更改TextInputLayouts上浮动标题的大小
有没有办法更改上升到TextInputLayout顶部的标题的大小?我并没有试图更改框为空时显示的“提示”文本的大小 我想在以下位置更改“名称”的大小:Android 更改TextInputLayouts上浮动标题的大小,android,xml,android-edittext,android-textinputlayout,text-size,Android,Xml,Android Edittext,Android Textinputlayout,Text Size,有没有办法更改上升到TextInputLayout顶部的标题的大小?我并没有试图更改框为空时显示的“提示”文本的大小 我想在以下位置更改“名称”的大小: 当然,这可以通过为TextInputLayout创建样式来实现。 但实现这一目标更明确的方法是通过创造 文本外观样式 这样做的好处是,您可以为提示标签和错误标签提供单独的样式,您可以自定义颜色、大小等属性。 (如果需要,还可以在TextInputLayout中为EditText设置单独的样式。) 1.首先创建两种样式,如下所示: <s
当然,这可以通过为TextInputLayout创建样式来实现。 但实现这一目标更明确的方法是通过创造 文本外观样式 这样做的好处是,您可以为提示标签和错误标签提供单独的样式,您可以自定义颜色、大小等属性。 (如果需要,还可以在TextInputLayout中为EditText设置单独的样式。) 1.首先创建两种样式,如下所示:
<style name="TextInputStyle.Hint" parent="TextAppearance.AppCompat">
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textSize">16sp</item>
</style>
<style name="TextInputStyle.Error" parent="TextAppearance.AppCompat">
<item name="colorAccent">#ed2d2d</item>
<item name="android:textColor">#ed2d2d</item>
<item name="android:textSize">12sp</item>
</style>
@颜色/原色
@颜色/原色
16便士
#ed2d2d
#ed2d2d
12便士
2.然后在TextInputLayout中指定上述样式,如下所示:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/TextInputStyle.Error"
app:hintTextAppearance="@style/TextInputStyle.Hint">
</android.support.design.widget.TextInputLayout>
希望对您有所帮助:)当然,这可以通过为TextInputLayout创建样式来实现。 但实现这一目标更明确的方法是通过创造 文本外观样式 这样做的好处是,您可以为提示标签和错误标签提供单独的样式,您可以自定义颜色、大小等属性。 (如果需要,还可以在TextInputLayout中为EditText设置单独的样式。) 1.首先创建两种样式,如下所示:
<style name="TextInputStyle.Hint" parent="TextAppearance.AppCompat">
<item name="colorAccent">@color/colorPrimary</item>
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textSize">16sp</item>
</style>
<style name="TextInputStyle.Error" parent="TextAppearance.AppCompat">
<item name="colorAccent">#ed2d2d</item>
<item name="android:textColor">#ed2d2d</item>
<item name="android:textSize">12sp</item>
</style>
@颜色/原色
@颜色/原色
16便士
#ed2d2d
#ed2d2d
12便士
2.然后在TextInputLayout中指定上述样式,如下所示:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/TextInputStyle.Error"
app:hintTextAppearance="@style/TextInputStyle.Hint">
</android.support.design.widget.TextInputLayout>
希望对您有所帮助:)您可以为标签文本添加自定义样式。选中此处的答案可以为标签文本添加自定义样式。在这里检查答案