2015-02-17 4 views
6

इस पर नया है और एंड्रॉइड प्रोग्रामिंग के लिए काफी नया है।मल्टीलाइन एडिटटेक्स्ट और इसके आगे के बटन के लिए व्हाट्सएप-जैसे लेआउट

मैं व्हाट्सएप चैट गतिविधि में एक लेआउट बनाने की कोशिश कर रहा हूं। तो मैं जो हासिल करना चाहता हूं वह उसी लेआउट और व्यवहार को एडिटटेक्स्ट और इसके बगल में बटन के लिए प्राप्त करना है। इसका मतलब मध्य में स्माइलीज़ और एडिटटेक्स्ट के लिए बाएं बटन और पाठ भेजने के लिए दाईं ओर एक बटन है।

व्हाट्सएप में जब एडिटटेक्स्ट अपने आकार (मल्टीलाइन) का विस्तार करता है तो बटन नीचे रहते हैं। लेकिन ऐसा लगता है कि मूल दृश्य के नीचे नहीं होना चाहिए क्योंकि बटन पहले संपादन टेक्स्ट में केंद्रित हैं।

मैंने टेबललेआउट की पंक्ति में तीन विचार डालने की कोशिश की। या सिर्फ एक रिलेवेटिवआउट का उपयोग कर। लेकिन इसका कुछ भी ठीक से काम नहीं करता है।

क्या कोई मुझे दिखा सकता है कि इसे कैसे प्राप्त किया जाए? मैं अपना एक्सएमएल प्रदान कर सकता हूं लेकिन .... अच्छा ... यह स्पष्ट रूप से बहुत खराब है: डी

अग्रिम धन्यवाद!

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin"> 

<ListView 
    android:id="@+id/messages" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:layout_above="@+id/footer_section"> 
</ListView> 

<LinearLayout 
    android:id="@+id/footer_section" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:minHeight="48dp"> 

     <ImageView 
      android:id="@+id/emoticons_button" 
      android:layout_height="match_parent" 
      android:layout_width="48dp" 
      /> 

     <EditText 
      android:id="@+id/message_text" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent" 
      android:layout_weight="1" 
      android:inputType="textMultiLine" 
      android:minLines="1" 
      android:maxLines="4"/> 

     <ImageView 
      android:id="@+id/send_button" 
      android:layout_height="match_parent" 
      android:layout_width="48dp" 
      android:layout_gravity="center_vertical"/> 

</LinearLayout> 

enter image description here

enter image description here

+0

अपने xml –

उत्तर

13

संपादित

<ListView 
    android:id="@+id/messages" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/footer_section" 
    android:layout_alignParentTop="true" > 
</ListView> 

<LinearLayout 
    android:id="@+id/footer_section" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal" 
    android:background="#eeeeee"> 

    <ImageView 
     android:id="@+id/emoticons_button" 
     android:layout_width="48dp" 
     android:layout_height="match_parent" /> 

    <EditText 
     android:id="@+id/message_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="vertical" 
     android:fadeScrollbars="false" 
     android:layout_weight="1" 
     android:inputType="textMultiLine" 
     android:maxLines="4" 
     android:minLines="1" 
     android:textColor="@android:color/black" /> 

    <ImageView 
     android:id="@+id/send_button" 
     android:layout_width="48dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_vertical" /> 
</LinearLayout> 

जैसा कि आपने कहा आप एंड्रॉयड में नौसिखिया हैं, तो आपका उपयोग कर प्रयास करना चाहिए लेआउट के लिएजो आप प्राप्त करना चाहते हैं। एक्सएमएल नीचे

प्रयास करें:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" 
android:weightSum="1" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="1dip" 
    android:gravity="center_vertical" 
    android:orientation="horizontal" > 

    <ImageButton 
     android:id="@+id/btn_emoticon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_emoticon" /> 

    <EditText 
     android:id="@+id/chat_text" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.0" 
     android:paddingLeft="8dp" 
     android:paddingRight="6dp" /> 

    <ImageButton 
     android:id="@+id/btn_send" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_send_grey" /> 
</LinearLayout> 
</LinearLayout> 
+0

हाय डोरि, बहुत बहुत शुक्रिया प्रदान करें। ठीक है, मुझे लगता है कि मुझे वज़न और लेआउट_वेट विशेषताओं के साथ थोड़ा सा सौदा करना चाहिए। मैं इसे अभी तक एक रिलेवेटिवआउट में काम कर रहा हूं। तो ऊपर वर्णित इस पाद लेख खंड के ऊपर एक सूची दृश्य है। लेकिन अब समस्या यह है कि जब स्क्रीन पर कीबोर्ड दिखाया जाता है तो संपादन टेक्स्ट वास्तव में विस्तार नहीं करता है। अगर मैं कीबोर्ड को छुपाता हूं तो यह करता है। खैर .... अगर आप मेरी मदद कर सकते हैं तो यह एक्सएमएल फाइल प्रदान करना सबसे अच्छा हो सकता है। मैं इसके बारे में थोड़ा शर्मिंदा हूं जाहिर है इसमें गलतफहमी या समझ में आने के कारण कुछ गलतियां हैं :- – marcus

+0

हाय @marcus, मुझे आपकी समस्या वास्तव में समझ में नहीं आया। क्या आप मुझे और अधिक सटीक बता सकते हैं कि आपकी आवश्यकता क्या है। – Dory

+0

हाय डोरी, क्षमा करें। तो मैंने दो चित्र जोड़े। मैं एडिटटेक्स्ट को अधिकतम 4 लाइनों को दिखाने के लिए चाहता हूं। इसलिए जब मैं टेक्स्ट दर्ज करता हूं तो पैरेंट लाइनरलाइट को अपनी ऊंचाई को एडिटटेक्स्ट ऊंचाई या रेखाओं के अनुसार दिखाया जाना चाहिए। लेकिन जब कीबोर्ड दिखाया जाता है तो यह ऐसा नहीं करता है। अगर मैं कीबोर्ड बंद करता हूं तो एडिटटेक्स्ट अधिकतम 4 लाइनों को दिखाता है और पैरेंट लाइनरलाउट में भी बड़ी ऊंचाई होती है। लेकिन जब मैं टेक्स्ट दर्ज करता हूं और कीबोर्ड को दिखाया जाता है तो मैं इसे पहले ही प्राप्त करना चाहता हूं। क्या आपको मिला – marcus

संबंधित मुद्दे