8

के नीचे फ्रेमलेआउट के अंदर मेल नहीं खाता है। मैं चैट रूम के लिए भाषण बबल बनाने की कोशिश कर रहा हूं। प्रत्येक भाषण बुलबुले में संलग्न एक्सएमएल लेआउट होता है।एंड्रॉइड छवि दृश्य नीचे ग्राफ़रब्रेड

मैं TextView निर्धारित करके इसे प्राप्त करने हूँwrap_content, स्पीच बबल imageView करनेmatch_parent और frame_layout को wrap_content करने के लिए। ताकि बबल में टेक्स्ट की मात्रा के अनुसार टेक्स्ट के पीछे भाषण_बबल छवि।

मैं माता पिता और ऊंचाई wrap_content को मैच के लिए TextView पर चौड़ाई सेट और किसी कारण से, यह पूरी तरह से काम करता है रूप आइस क्रीम सैंडविच (Android 4.1) में आवश्यक के लिए। हालांकि में जिंजरब्रेड आंतरिक छवि दृश्य भाषण बबल मेल_पैरेंट पर स्केल नहीं करता है ताकि टेक्स्ट बबल के अंदर अच्छी तरह से फिट हो सके। जिंजरब्रेड में आंतरिक छवि दृश्य पाठ के बावजूद पाठ और टेक्स्ट ओवरफ्लो के बगल में के समान आकार हमेशा रहता है। हालांकि frameLayoutwrap_content, imageView के लिए विस्तारित नहीं है match_parent के रूप में यह माना जाता है।

यह क्यों हो रहा है पर कोई विचार? क्या कोई और पैरामीटर है जिसे मैं xml या एक विधि के माध्यम से सेट कर सकता हूं जिसे मैं प्रोग्रामेटिक रूप से ठीक करने के लिए कॉल कर सकता हूं?

धन्यवाद! आईसीएस में

सही व्यवहार:

Correct Behavior in ICS

जिंजरब्रेड में गलत व्यवहार: Incorrect Behavior in GingerBread

एक्सएमएल लेआउट:

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 
     <FrameLayout 
            xmlns:android="http://schemas.android.com/apk/res/android" 
            android:id="@+id/speech_bubble_framelayout" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:orientation="horizontal" 
            android:background="@color/color_transparent" 
            android:layout_toRightOf="@id/message_user_imageView"> 

        <ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
                   android:id="@+id/message_background_imageview" 
                   android:layout_width="match_parent" 
                   android:layout_height="match_parent" 
                   android:layout_margin="5dp" 
                   android:scaleType="fitXY" 
                   android:layout_centerInParent="true" 
                   android:textColor="@color/color_brown_mud" 
                   android:background="@drawable/chat_bubble_flipped" 
                /> 
        <TextView 
                android:id="@+id/message_textView" 
                android:layout_width="wrap_content" 
                android:layout_height="match_parent" 
                android:maxEms="10" 
                android:background="@color/color_transparent" 
                android:textColor="@color/color_brown_uiDesign_pallete" 
                android:textSize="15sp" 
                android:textStyle="bold" 
                android:gravity="center_horizontal" 
                android:text="Message" 
                android:padding="5dp" 
                android:layout_marginLeft="25dp" 
                android:layout_marginRight="20dp" 
                android:layout_marginTop="15dp" 
                android:layout_marginBottom="15dp" 
                /> 
    </FrameLayout> 
</merge> 

उत्तर

24

यह दिखता है से, यह एक के कारण होता है आपके आकार में परिपत्र निर्भरता: आंतरिक पाठ और छवि आकार फ़्रेमलेआउट पर निर्भर है (match_parent), जबकि फ़्रेमलेआउट का आकार इसके अंदर मौजूद है (wrap_content) पर निर्भर है। फ़्रेमलेआउट का उपयोग निराश हो जाता है जहां इस तरह के कारण से एक से अधिक बच्चे शामिल होते हैं। सुरक्षा के लिए, मैं FrameLayout एक RelativeLayout के लिए बदल रहा है, और भीतरी छवि देखने पर निम्नलिखित संपत्ति की स्थापना की सलाह देते हैं:

android:layout_alignTop="@+id/message_textview" 
android:layout_alignBottom="@+id/message_textview" 

यह अपनी छवि हमेशा आपका पाठ के आकार तक के मेल खाता सुनिश्चित करेगा।

+0

इस मुद्दे को ठीक किया गया। मैंने कुछ पैडिंग के साथ alignBottom और alignRight का उपयोग किया। धन्यवाद! – Bala