我正在嘗試爲我的應用程序編寫一般的style.xml。Android:使用一般風格應用邊距不起作用
我想我所有的EditText的意見有一定的風格,所以我做了這樣的事情:
<!-- Base application theme. -->
<style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:editTextStyle">@style/App_EditTextStyle</item>
</style>
<style name="App_EditTextStyle">
<item name="android:background" >#ff0000</item>
<item name="android:textColor">#00ff00</item>
<item name="android:layout_marginLeft">50dip</item>
<item name="android:height">50dip</item>
</style>
在清單我應用的主題:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyAppTheme" >
這裏是樣品佈局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:text="Test" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:text="Test2" />
</LinearLayout>
一切工作正常,除了保證金。出於某種原因,它不適用,我必須手動添加到EditText。我錯過了什麼嗎?
參見[這個答案](http://stackoverflow.com/a/13365288/2052936) – igork