Reputation: 133
I'm creating layout with ImageView and HorizontalScrollView. It looks like the image below..
when the user click one of the image at HorizontalScrollView it will display bigger image at ImageView..
so far my code is below
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageViewTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<HorizontalScrollView
android:id="@+id/mainHorizontalScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/orange"
>
<ImageView
android:id="@+id/image1"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="fitXY"
android:src="@drawable/pic1"
android:padding="15dp"
></ImageView>
<ImageView
android:id="@+id/image2"
android:layout_width="150dp"
android:layout_height="150dp"
android:scaleType="fitXY"
android:src="@drawable/pic2"
android:padding="15dp"
></ImageView>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
above code make the ImageView fill the entire screen..what i want is the ImageView fill the remaining screen that not filled by the HorizontalScrollView.. How to do this??
Upvotes: 2
Views: 4493
Reputation: 5322
Change the ImageView
to be:
<ImageView
android:id="@+id/imageViewTop"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=1
android:layout_alignParentTop="true"
/>
And make the parent View a LinearLayout
Upvotes: 6
Reputation: 176
change the parent layout to LinearLayout and add use weights on ImageView and child RelativeLayout as follows,
<LinearLayout ....
......>
<ImagView layout-weight="1"...
...../>
<RelativeLayout layout-weight="0.6"..
......>
<!-- child Views -->
</RelativeLayout>
</LinearLayout>
Change the values of weight according your requirement, hope this helps
Upvotes: 0