hi I have a activity with three vertical linear layout with respective layout_weight with orientation vertical . I have added 10 image to left and right linear layout . Middle layout is empty.
I want to add scroll view in both left and right linear layout , so that if screen is small , then user able to scroll to see all images in linear layout .
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:id="@+id/layoutPositionRow"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:padding="8px"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".6" android:layout_gravity="center_vertical">
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight=".2" android:layout_gravity="center_vertical">
</LinearLayout>
</LinearLayout>
Whether It is possible.
Please suggest me usable link or sample code.
Just wrap your scrollable layouts into
ScrollViews like in this code:Here, I used
layout_widthattribute value for all of the elements as 0dp because of usinglayout_weight. And also if you would like to position elements in your layouts bycenter_vertcialyou should useandroid:gravityattribute instead ofandroid:layout_gravity. The last one tells the system how to position layouts on theirScrollViews.