imageview weights in linearlayout
Posted
by
Metalex
on Stack Overflow
See other posts from Stack Overflow
or by Metalex
Published on 2012-08-28T17:54:32Z
Indexed on
2012/08/28
21:38 UTC
Read the original article
Hit count: 467
I have this layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:minWidth="100dp" >
<TextView
android:id="@+id/txt_what_way"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="4"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="3">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher"/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="3">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher"/>
</LinearLayout>
</LinearLayout>
I want that it looks like:
TextView - 40% of width, Layout with ImageView - 30% of widht, Layout with ImageView - 30% of width.
But the output is:
TextViewImageViewImageView----------------free space----------------------------------
Thanks for your help!
-- EDITED
Done it in programmatic way
© Stack Overflow or respective owner