我想在Android material EditText中更改浮动标签文本大小,设置如下:
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/str_current"
android:inputType="number"
android:singleLine="true"
android:textSize="20sp" />它只是改变提示和输入文本的文本大小。
由于浮动标签文本大小在我的UI中似乎太小,我想要更改它,有什么解决方案吗?
发布于 2016-02-15 20:56:32
尝试下面的代码。这可能会对你有所帮助:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/TextAppearance.AppCompat.Medium.Inverse">您可以改用app:hintTextAppearance="@style/TextAppearance.AppCompat.Small.Inverse"。
发布于 2016-02-15 21:50:30
公认的答案对我找到解决方案有很大帮助(例如,设置准确的字体大小,而不仅仅是使用small,medium,...)。
此外,通过为app:hintTextAppearance定义样式,您还可以简单地设置浮动标签的颜色:)
在styles.xml中:
<style name="CustomTextAppearance" parent="@android:style/TextAppearance">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/colorAccent</item>
</style>在你的TextInputLayout中:
<android.support.design.widget.TextInputLayout
android:id="@+id/lyt_goal"
style="@style/CustomTextInput"
app:hintTextAppearance="@style/CustomTextAppearance">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/edt_goal"
android:hint="@string/str_goal" />
发布于 2016-02-15 19:37:23
尝试下面的代码,它在正常状态下工作
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Hiiiii"
android:id="@+id/edit_id"/>
</android.support.design.widget.TextInputLayout>样式文件夹TextLabel
中的代码
<style name="TextLabel" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">@color/Color Name</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">@color/Color Name</item>
<item name="colorControlNormal">@color/Color Name</item>
<item name="colorControlActivated">@color/Color Name</item>
</style>设置为应用程序的主主题,它仅适用于突出显示状态
<item name="colorAccent">@color/Color Name</item>希望这能对你有所帮助!
https://stackoverflow.com/questions/35408283
复制相似问题