layout_width和layout_height不适用于主题的edittext [英] layout_width and layout_height is not applying to edittext from the theme

查看:75
本文介绍了layout_width和layout_height不适用于主题的edittext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面,我在主题中添加了 EditText 样式.我也增加了宽度和高度.所以我从 edittext 视图中删除了 android:layout_width android:layout_height .但这是在说错误.如果我添加宽度和高度,它工作正常.有什么区别.主题不适用于我的edittext视图吗?

Below i have added EditText style in theme. I have added width and height also. So i removed android:layout_width and android:layout_height from my edittext view. But it is saying error. If i add width and height it is working fine. What is the difference. Is theme is not applying to my edittext view?

<style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
        <item name="android:editTextStyle">@style/custom_EditTextStyle</item>
</style>
<style name="custom_EditTextStyle" parent="@android:style/Widget.EditText">
         <item name="android:background">@drawable/edittextbox</item>
         <item name="android:singleLine">true</item>
         <item name="android:layout_width">fill_parent</item>
         <item name="android:layout_height">48dp</item>
    </style>

我的editText视图

My editText view

 <EditText android:hint="Username" />

推荐答案

您的 styles.xml 必须包含

<在顶部资源xmlns:android ="http://schemas.android.com/apk/res/android"> .

如果此文件是自动生成的,或者您是自己创建的,则有时会忘记此属性.

If this file was auto-generated or you made this file yourself, this attribute is sometimes forgotten.

这篇关于layout_width和layout_height不适用于主题的edittext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆