Search code examples
androidandroid-layoutscrollviewandroid-scrollview

Setting the properties for ScrollView in LinearLayout - Android


How do I set the properties for the following ScrollView's present in both LinearLayout so that they are scrollable. I'm programmatically adding views to both LinearLayouts.

    <ScrollView  > 
        <LinearLayout
            android:id="@+id/linearLeft"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_weight="0.2"
            android:background="#88FF0000"
            android:orientation="vertical" >
        </LinearLayout>
    </ScrollView>

    <ScrollView > 
        <LinearLayout
            android:id="@+id/linearRight"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_weight="0.8"
            android:background="#8800FF00"
            android:orientation="vertical" >
        </LinearLayout>
     </ScrollView>

 </LinearLayout>

Solution

  • I finally sorted out my problem and here is my code. Sorry for not being clear with my question.

    <ScrollView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:layout_weight="0.2" >
    
        <LinearLayout
            android:id="@+id/linearLeft"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#88FF0000"
            android:orientation="vertical" >
        </LinearLayout>
    </ScrollView>
    
    <ScrollView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:layout_weight="0.8" >
    
        <LinearLayout
            android:id="@+id/linearRight"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#8800FF00"
            android:orientation="vertical" >
        </LinearLayout>
     </ScrollView>