![](/img/trans.png)
[英]Why is it not possible to set layout_height and layout_width for toolbar in theme with toolbarStyle?
[英]layout_width and layout_height is not applying to edittext from the theme
下面我在主題中添加了EditText
樣式。 我還添加了寬度和高度。 所以我從我的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>
我的編輯文本視圖
<EditText android:hint="Username" />
你的styles.xml
必須包含
<resources xmlns:android="http://schemas.android.com/apk/res/android">
在頂部。
如果此文件是自動生成的,或者您自己制作了此文件,則有時會忘記此屬性。
您需要將樣式應用於EditText
:
<EditText android:hint="Username"
style="@style/custom_EditTextStyle" />
編輯:根據您的評論,我認為這就是您想要的:
<EditText android:hint="Username"
android:layout_height="48dp"
android:layout_width="match_parent"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.