我在注册屏幕上使用TextinputEditText.我可以设置浮动标签的样式.我想使用样式在TextinputEditText的提示和文本上设置自定义字体.有谁知道这是怎么回事?
<androID.support.design.Widget.TextinputLayout androID:ID="@+ID/til_registration_name" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="16dp" androID:paddingEnd="@dimen/default_vIEw_padding_right_8dp" androID:paddingStart="@dimen/default_vIEw_padding_left_8dp" androID:textcolorHint="@color/colorSecondaryText" app:hintTextAppearance="@style/Apptheme.inputLayoutStyle" app:layout_constrainttop_toBottomOf="@ID/textvIEw_registration_Title"> <androID.support.design.Widget.TextinputEditText androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:hint="@string/registration_name" androID:imeOptions="actionNext" androID:singleline="true" androID:textcolor="@color/colorPrimaryText" /> </androID.support.design.Widget.TextinputLayout>
styles.xml
<style name="Apptheme.inputLayoutStyle" parent="TextAppearance.AppCompat"> <item name="androID:textcolor">@color/colorPrimary</item> <item name="FontFamily">@Font/lato_light</item></style><style name="Apptheme" parent="theme.AppCompat.light.NoActionbar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> <item name="androID:textVIEwStyle">@style/Apptheme.TextVIEw</item> <item name="buttonStyle">@style/Apptheme.button</item></style>
我想为整个应用程序设置样式.
解决方法:
旧问题,但值得回答.
只需在应用程序主题中设置“ textinputStyle”以设置TextinputLayouts的样式,并设置“ editTextStyle”以设置TextinputEditTexts的样式.
<style name="Apptheme" parent="theme.AppCompat.light.NoActionbar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> <item name="androID:textVIEwStyle">@style/Apptheme.TextVIEw</item> <item name="buttonStyle">@style/Apptheme.button</item> <item name="textinputStyle"> @style/MyCustomTextinputStyle </item> <item name="editTextStyle"> @style/MyCustomEditTextStyle </item></style><style name="MyCustomTextinputStyle" parent="Widget.Design.TextinputLayout"> <item name="androID:textcolorHint">@color/colorSecondaryText</item> <item name="hintTextAppearance">@style/any_style_you_may_want"</item></style><style name="MyCustomEditTextStyle" parent="Widget.AppCompat.EditText"> <item name="androID:textcolor">@color/colorPrimary</item> <item name="FontFamily">@Font/lato_light</item></style>
这会将相同的样式应用于应用程序中的所有TextinputLayout和TextinputEditText.
总结以上是内存溢出为你收集整理的android-如何在styles.xml中设置TextInputEditText的样式全部内容,希望文章能够帮你解决android-如何在styles.xml中设置TextInputEditText的样式所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)