Krishnabhadra
Krishnabhadra

Reputation: 34275

android layout scale along with content imageView's

I have a relative layout and in that I have 4 imageViews stacked one on the top of another.

I have a set of layout like this, where I have a Linear Layout and a Relative layout on one on top of another.

<LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0" android:background="#5500FF00"
    android:orientation="vertical" android:gravity="center_horizontal|bottom" android:paddingBottom="3dip">
    <include layout="@layout/app_tax_coin_subsection"/>
</LinearLayout>

In the linear layout I am including another relative layout from another xml file which has a number of boxes on top of one another..

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/app_income_coin_id"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/box_red"
            android:id="@+id/box1" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" android:visibility="visible"/>
        <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/box_red"
            android:layout_above="@id/box1" android:layout_centerHorizontal="true" android:id="@+id/box2" android:visibility="visible"/>
        <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/box_red"
            android:layout_above="@id/box2" android:layout_centerHorizontal="true" android:id="@+id/box3" android:visibility="visible"/>
        <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/box_red"
            android:layout_above="@id/box3" android:layout_centerHorizontal="true" android:id="@+id/box4" android:visibility="visible"/>
    </RelativeLayout>

The above code working correctly and I am getting 4 lovely red boxes one on top of another. Now I want to reduce the size and width of the relative layout and I want these boxes to reduce size as well. In short what can I do to make the content imageView to resize(even to a size smaller than the original image size) along with its parent layout?

Upvotes: 0

Views: 2205

Answers (1)

Robby Pond
Robby Pond

Reputation: 73484

The layout height and width of the RelativeLayout are FILL_PARENT so they will take up the full screen. You can start by setting an absolute height/width in dps, the ImageViews will scale down to fit the parent.

Upvotes: 1

Related Questions