<merge>
टैग प्रतिपादन लेआउट के प्रदर्शन को बढ़ाने के लिए स्तरों की संख्या कम करने के लिए प्रयोग किया जाता है: <merge>
समाधान के रूप में नीचे दी गई है। टैग का उपयोग <include>
टैग के साथ पूरी तरह से किया जाता है।
एक उदाहरण लें, हमारे पास एक लॉगिन लेआउट है और हमारे ऐप के दायरे में एक से अधिक के लिए उपयोग किया जाता है। Login_layout दिखाने के लिए टैग का उपयोग करते समय, हम एक स्तर से बच सकते हैं और बच सकते हैं।
मैं आपको लेआउट के बारे में चाल पढ़ने के लिए भी सलाह देता हूं। http://android-developers.blogspot.com.tr/2009/03/android-layout-tricks-3-optimize-by.html
login_form.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Login form -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email..."
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:visibility="visible" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password.."
android:imeActionId="@+id/login"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:text="1337"
android:visibility="visible" />
<Button
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16sp"
android:paddingLeft="32sp"
android:paddingRight="32sp"
android:text="Login"
android:visibility="visible" />
</LinearLayout>
example_layout.xml (किसी भी लेआउट हम login_form.xml शामिल करना चाहते हैं)
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
<include layout="@layout/login_form" />
</merge>
हम स्तरीय पदानुक्रम देख सकते हैं
कृपया बंद पर एक नज़र डालें आईसीअल एंड्रॉइड प्रलेखन: [ के साथ लेआउट का पुन: उपयोग करना] (http://developer.android.com/training/improving-layouts/reusing-layouts.html) –
JJD
http://stackoverflow.com/a/11093340/596555, आपकी मदद कर सकता है – boiledwater
एफवाईआई, यदि आप ** मेनू ** के साथ इसका उपयोग करना चाहते हैं, तो आप भाग्य से बाहर हैं, लेकिन आप यहां वर्णित कई एक्सएमएल फाइलों को बढ़ा सकते हैं: http: // stackoverflow।कॉम/प्रश्न/4337034/शामिल-मेनू-इन-मेन्यू-एंड्रॉइड –