Reputation: 3990
I am trying to create a 3 column view in android where column 1 shows a 48x48dp icon, the second shows 2 lines of content(a title and some intro) and the third shows the amount(a numeric)
This is what i am using to create it, but this is showing a VERY tall entry in the list.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/cloudbkg"
android:padding="10dp" >
<ImageView
android:id="@+id/pic"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/pay" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/service"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="amit is here to test it over n over again!"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From " />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Walmart " />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some t" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/amount"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="right"
android:singleLine="true"
android:text="$99"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
What am i doing wrong here?
Upvotes: 1
Views: 2138
Reputation: 430
I have used relative layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:background="#ff00ff" >
<ImageView
android:id="@+id/pic"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:padding="2dp"
android:text="$99"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/amount"
android:layout_toRightOf="@+id/pic"
android:singleLine="true"
android:text="amit is here to test it over n over again!"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/service"
android:layout_toLeftOf="@+id/amount"
android:layout_toRightOf="@+id/pic"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From " />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Walmart " />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some t" />
</LinearLayout>
</RelativeLayout>
Upvotes: 2