मैं वास्तव में करने की कोशिश की, लेकिन मैं नहीं समझ सकता कैसे एंड्रॉयड layout_weight
सेटिंग की व्याख्या ...समस्याएं समझने एंड्रॉयड एक्सएमएल layout_weight
क्या मैं प्राप्त करने के लिए कोशिश कर रहा हूँ
- साथ शीर्ष पर एक शीर्षक है एक निश्चित ऊंचाई
- एक EditText और एक बटन से युक्त नीचे इनपुट क्षेत्र
- बीच में एक सामग्री बात यह है कि सभी ले रहा है क्या अंतरिक्ष के बचा है
टाइप करते समय मैं एडिटटेक्स्ट को एक विशिष्ट ऊंचाई पर बढ़ाना चाहता हूं और स्क्रॉलिंग शुरू करना चाहता हूं यदि पाठ दर्ज की गई ऊंचाई से अधिक हो। ऐसा करने के लिए मुझे संपादन टेक्स्ट के साथ एक साथ बढ़ने के लिए आसपास के LinearLayout
की आवश्यकता है।
यदि मैं आंतरिक LinearLayout
के लिए एक विशिष्ट ऊंचाई को परिभाषित करता हूं तो यह नहीं बढ़ेगा। यदि मैं नहीं करता, आंतरिक लेआउट स्क्रॉलव्यू के बजाए सभी जगह लेता है, इससे कोई फर्क नहीं पड़ता कि मैं layout_weight
का उपयोग करने का प्रयास करता हूं। :(
मेरे वर्तमान एक्सएमएल कि तरह लग रहा है:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I'm a header" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="bottom">
<LinearLayout
android:id="@+id/itemContainer"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:padding="2dp"
android:gravity="bottom"
android:isScrollContainer="true"
android:background="@drawable/steel" >
<EditText
android:id="@+id/edittext01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:scrollbars="vertical"
android:fadingEdge="vertical"
android:fadingEdgeLength="60dp"
android:maxHeight="40dp"
android:textSize="15sp" />
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:layout_gravity="right"
android:text="Send"
android:textStyle="bold"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
कोई युक्ति बहुत सराहना कर रहे हैं
धन्यवाद माया। यही वही है जो मैं करने की कोशिश करता हूं। शायद kcoppock एक और विचार है। यदि यह होना चाहिए तो मैं विभिन्न समाधानों के लिए लेआउट तैयार कर दूंगा। :(स्क्रॉलव्यू को एक विशिष्ट आकार में सेट करना और लेआउट_वेट = 1 जोड़ना स्क्रॉलव्यू को प्राप्त करने वाली सभी जगहों को ले सकता है और जैसे ही कुछ अन्य विजेट अधिक स्थान लेता है, ठीक है? – stpn108
यूप, विचार। –
सही लगता है।मेरा मानना है कि एडिटटेक्स के लिए एक सेटमल्टीलाइन विशेषता है। यदि आप इसे सेट करते हैं, और ऊंचाई को wrap_content पर सेट करते हैं, तो मुझे पूरा यकीन है कि यह फिट करने के लिए विस्तारित होगा, और तदनुसार स्क्रॉलव्यू को छोटा कर देगा। – kcoppock