Android - marginesy określone w niestandardowym stylu nie działają
Chcę, aby domyślny margines dla EditText wynosił 10dp. Dlatego w moim pliku styles.xml skonfigurowałem następujące elementy:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="android:style/Theme.NoTitleBar">
<item name="android:editTextStyle">@style/edit_text_default</item>
</style>
<style name="edit_text_default" parent="android:style/Widget.EditText">
<item name="android:layout_margin">10dp</item>
</style>
</resources>
Następnie w pliku AndroidManifest.xml ustawiłem motyw aplikacji na zdefiniowany przeze mnie:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
...
Aspekt „No Title Bar” działa. Jednak domyślny margines dla EditText nie jest, to wciąż wypełnia rodzica. Oto mój widok tabeli:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF" >
<TableRow>
<EditText android:hint="@string/last_name" />
</TableRow>
<TableRow>
<EditText android:hint="@string/first_name" />
</TableRow>
</TableLayout>