मैं एडिटटेक्स्ट के 10 डीपी के लिए डिफ़ॉल्ट मार्जिन चाहता हूं। इसलिए, मेरा styles.xml फ़ाइल में मैं निम्नलिखित की स्थापना:एंड्रॉइड - कस्टम शैली में निर्दिष्ट मार्जिन प्रभाव नहीं ले रहे
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
...
"कोई शीर्षक पट्टी:
<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>
फिर AndroidManifest.xml में
, मैं एक मैं परिभाषित करने के लिए आवेदन पत्र विषय सेट "विषय का पहलू काम कर रहा है। हालांकि, EditText के लिए डिफ़ॉल्ट मार्जिन नहीं है, यह अभी भी अभिभावक को भर रहा है। यहां मेरा टेबल व्यू है:
<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>
डब्ल्यू ... टी ... एफ ?? क्यूं कर? क्यूं कर? क्यूं कर?!?! ... कृपया मुझे माफ़ कर दो ... मैं एंड्रॉइड विकास के सभी quirks के साथ अपना दिमाग खो रहा हूँ। – pbarranis
यह उत्तर कुछ हद तक असंतोषजनक है - लेआउट मार्जिन तब भी लागू नहीं होते हैं जब माता-पिता ViewGroup और बच्चे दृश्य एक ही लेआउट xml फ़ाइल में होते हैं। इस मामले में inflater * * माता-पिता ViewGroup के ठोस प्रकार के बारे में जानता है (क्योंकि यह इसे अभी बढ़ाता है) और लागू करने के लिए शैली को भी जानता है (क्योंकि अन्य शैली विशेषताओं को लागू किया जाता है)। –