2011-05-26 15 views
5

मैं इस तरह सरल लेआउट है: (यह मेल के लिए है)स्क्रीन भरने के लिए लेआउट कैसे फैलाएं?

<ScrollView android:layout_height="0dp" android:layout_width="fill_parent" android:layout_weight="1" android:background="@color/red_start"> 

     <LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" android:background="@color/blue_start"> 

      <TextView style="@style/MyTextViewLabel" android:text="From" android:layout_marginTop="5dp"/> 

      <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded"> 
       <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_sender" /> 
      </LinearLayout> 

      <TextView style="@style/MyTextViewLabel" android:text="Subject" android:layout_marginTop="5dp"/> 

      <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded"> 
       <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_subject" /> 
      </LinearLayout> 

      <TextView style="@style/MyTextViewLabel" android:text="Body" android:layout_marginTop="5dp"/> 

      <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/shape_white_rounded"> 
       <TextView style="@style/MyTextViewLabel.Black" android:id="@+id/tv_body" /> 
      </LinearLayout> 

     </LinearLayout> 

    </ScrollView> 

किसी कारण LinearLayout scrollview को भरने नहीं होगा के रूप में मैं उम्मीद के लिए। असल में, मैं tv_body को स्क्रीन भरने के लिए बनाना चाहता हूं और यदि कोई और टेक्स्ट है - तो इसे स्क्रॉल करने योग्य होना चाहिए। अभी यह ऐसा दिखता है। मुझे लगता है कि scrollview खिंचाव वर्णन करने के लिए रंग डाले, लेकिन LinearLayout अगर आप android:layout_height="match_parent" करने के लिए अपने scrollview में android:layout_height="0dp" बदल क्या होता है नहीं होता है ..

enter image description here

उत्तर

37

कोशिश अपने scrollview में

android:fillViewport="true" 

जोड़ने के लिए। अधिक स्पष्टीकरण के लिए

चेकआउट इस: http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/

+0

महान नहीं किया, धन्यवाद! उसने – katit

+0

शानदार काम किया, मुझे भी मदद की .. – bluszcz

+0

मैंने स्क्रॉल व्यू के अंदर रैखिक लेआउट को नेस्टेड किया है। यह उस मामले में काम नहीं करता है :( –

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