Set a LinearLayout to scroll

前端 未结 5 703
时光说笑
时光说笑 2020-12-12 03:12

I have been reading many posts here in stackoverflow about making a linear layout scroll and have applied all the specific advices to make it work but it still does not show

相关标签:
5条回答
  • 2020-12-12 03:16

    I hope this code may be help you.

        android:layout_width="match_parent"
        android:layout_height="match_parent">
    

    0 讨论(0)
  • 2020-12-12 03:21

    Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)

    0 讨论(0)
  • 2020-12-12 03:24

    add

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    

    to your root ScrollView

    0 讨论(0)
  • 2020-12-12 03:31

    use this :

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView ...>
    
    <LinearLayout ...>
    
    ...
    ...
    
    </LinearLayout>
    
    </ScrollView>
    

    and set hieght to

    android:layout_height="wrap_content"
    

    as Karakuri said

    0 讨论(0)
  • 2020-12-12 03:33
    <?xml version="1.0" encoding="utf-8"?>
    
    <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent">
    
        //Your Main Layout
    
        <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:orientation="vertical"     
         android:weightSum="100">
    
        // First Sub Layout Under Main Layout
           <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" 
            android:layout_weight="10"
            android:weightSum="100" >
    
               <TextView
                android:id="@+id/textView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="TextView" 
                android:layout_weight="70" />
    
               <EditText
                android:id="@+id/editText1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="30" />
    
            </LinearLayout>// Finishing First Sub layout 
    
    // Second Sub Layout Under Main Layout
           <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" 
            android:layout_weight="10"
            android:weightSum="100" >
    
               <TextView
                android:id="@+id/textView2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="TextView" 
                android:layout_weight="70" />
    
               <EditText
                android:id="@+id/editText2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="30" />
    
            </LinearLayout>// Finishing Second Sub layout 
    
    similarly for 3rd,4rth,5th sub layouts and so on........
    
    </LinearLayout> // Finishing Main Layout
    </ScrollView>   // Finishing ScrollView 
    
    0 讨论(0)
提交回复
热议问题