2012-12-04 10 views
7

मैं इस तरह एक लेआउट के साथ एक कस्टम संवाद बंद बटन धक्का:scrollview साथ एंड्रॉयड कस्टम संवाद स्क्रीन

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/mylayout"> 
    <LinearLayout 
     android:id="@+id/title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <TextView ... /> 
     <TextView .../> 
    </LinearLayout> 
    <ScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/title"> 
     <LinearLayout ...> 
      <TextView ... 
       android:text="lots of text........" /> 
      <TextView .../> 
     </LinearLayout> 
    </ScrollView 
    <RelativeLayout ... 
    android:layout_below="@+id/scrollView"> 
    <Button ...> 
    <Button ...> 
    </RelativeLayout> 
</RelativeLayout> 

मेरे समस्या यह है कि scrollview है यह है कि जब वहाँ scrollview में बहुत अधिक लेख है, नीचे दिए गए बटन संवाद से बाहर धकेल दिए गए हैं। मैं RelativeLayout को एंकर करके इसे रोकने में सक्षम हूं जिसमें एंड्रॉइड का उपयोग करके नीचे दिए गए बटन शामिल हैं: layout_alignParentBottom = "true", लेकिन स्क्रॉलव्यू में कम टेक्स्ट होने पर मैं पूरे संवाद को स्क्रीन के नीचे खींचता हूं और मुझे वह नहीं चाहिए।

कैसे मैं इस तरह एक लेआउट प्राप्त कर सकते हैं:

[SOME TEXT] 
[Scrollable region] 
[Buttons] 
+0

300dip –

+0

की तरह मुख्य लेआउट की ऊंचाई ठीक करने का प्रयास मैं मुख्य लेआउट की ऊंचाई तय करने के लिए नहीं करना चाहते हैं, क्योंकि यह अलग स्क्रीन आकार और झुकाव –

उत्तर

6

RelativeLayout के बजाय LinearLayout एक अलग लेआउट में बटन रखो और बटन लेआउट पर एक वजन डाल की कोशिश करो।

LinearLayout - top level start, android:layout_weight="0" 
LinearLayout with TextViews embeded, android:layout_weight="1" 
LinearLayout with ScrollView embeded, android:layout_weight="1" 
LinearLayout with Buttons embeded, android:layout_weight="1" 
LinearLayout - top level finish, android:layout_weight="0" 
+0

यहां तक ​​कि के साथ एक रैखिक लेआउट कंटेनर का उपयोग करने पर पुनः आकार देने योग्य होने की जरूरत है एक वजन = 1 विशेषता, बटन अभी भी नीचे धकेल दिए गए हैं और आधे रास्ते में कटौती कर रहे हैं। तो यह थोड़ा बेहतर है, लेकिन एक पूर्ण समाधान नहीं ... –

+0

शीर्ष लेआउट को 'LinearLayout' में भी बदलें। फिर इस तरह कुछ है: अद्यतन मैंने इसे उत्तर में पोस्ट किया ... – Gix

+0

एचएम ... कोई भाग्य नहीं, संवाद अभी भी स्क्रीन से आगे फैला है और बटन को धक्का देता है ताकि वे आधे कट ऑफ हो जाएं। मेरे पास मेरे बटन और टेक्स्ट पर कुछ मार्जिन हैं, क्या वे लेआउट गणनाओं को प्रभावित करेंगे? –

1

भले ही सवाल यहां पुराना है, मेरे मामले में क्या मदद मिली है। उम्मीद है कि यह दूसरों की मदद कर सकता है क्योंकि मुझे नीचे ट्रेस करने में काफी समय लगा।

alertDialogBuilder.setMessage(null); 
+0

प्रश्न एक कस्टम संवाद के बारे में पूछा गया, एक चेतावनी संवाद नहीं। – Pkmmte