Pav*_*mar 4 android android-layout android-theme android-styles
下面我在主题中添加了EditText样式.我添加了宽度和高度alos.所以我从我的edittext视图中删除了android:layout_width和android:layout_height.但这是错误的说法.如果我添加宽度和高度它工作正常.有什么不同.主题不适用于我的edittext视图吗?
<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>
Run Code Online (Sandbox Code Playgroud)
我的editText视图
<EditText android:hint="Username" />
Run Code Online (Sandbox Code Playgroud)
你styles.xml必须包含
<resources xmlns:android="http://schemas.android.com/apk/res/android"> 在顶部.
如果此文件是自动生成的,或者您自己创建了此文件,则有时会忘记此属性.
您需要将该样式应用于EditText:
<EditText android:hint="Username"
style="@style/custom_EditTextStyle" />
Run Code Online (Sandbox Code Playgroud)
编辑:根据您的评论,我认为这就是您想要的:
<EditText android:hint="Username"
android:layout_height="48dp"
android:layout_width="match_parent"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2694 次 |
| 最近记录: |