PROBLEM
I want to adjust ImageView
base on percentage or weight but it can't.
Main Layout consists of 2 Layout inside,they equivalent to 1st row and 2nd row.
In the 1st row there are another 4 layout inside each one have an ImageView
.
I want these ImageView
to expand their height and width accordingly
by percentage or weight of its parents width height what should I do?
Is it possible to let its width scale in weight that I want and let's height
expand relative to its width?
PICTURE
XML LAYOUT
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/foot_bg">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center_horizontal"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView"
android:src="@drawable/ic_sleepmode"
android:scaleType="matrix"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sleep Mode"
android:id="@+id/textView3"
android:textColor="#ffffff"
android:textSize="10sp"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/linearLayout2"
android:gravity="center">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView2"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_temp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Temperature"
android:id="@+id/textView4"
android:textColor="#ffffff"
android:textSize="10sp"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/linearLayout5"
android:gravity="center">
<ImageView android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView5"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_tracking"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tracking Mode"
android:id="@+id/textView7"
android:textSize="10sp"
android:textColor="#ffffff"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/linearLayout6"
android:gravity="center">
<ImageView android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView6"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_settings"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:id="@+id/textView8"
android:textSize="10sp"
android:textColor="#ffffff"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/linearLayout"
android:gravity="center">
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New ToggleButton"
android:id="@+id/tgbPower"
android:layout_gravity="center_horizontal"
android:checked="false"/>
</LinearLayout>
</LinearLayout>
EDIT:
Try this to check if the imageview resizes with the weight: