I need to add 3 images in my custom window title bar. gravity
of 1st image is left
. gravity
of 2nd image is center
and gravity
of 3rd image is right
. I used the below code. but 3rd image not displaying. I think it is covered by 2nd image.
How can I display 3 images in above positions ?
<?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="35dip"
android:background="#323331"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="5dip" >
<ImageView
android:id="@+id/header_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/header_img_dec"
android:src="@drawable/left_logo" />
<ImageView
android:id="@+id/header_middle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/header_img_dec"
android:gravity="center" />
<ImageView
android:id="@+id/header_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:contentDescription="@string/header_img_dec"
android:src="@drawable/right_img" />
</LinearLayout>
Use layout weights for this, also set android:layout_gravity="center_horizontal"
for parent LinearLayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="35dip"
android:background="#323331"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:paddingLeft="5dip" >
<ImageView
android:id="@+id/header_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/header_img_dec"
android:src="@drawable/left_logo"
android:layout_weight="1"
/>
<ImageView
android:id="@+id/header_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/header_img_dec"
android:layout_weight="1" />
<ImageView
android:id="@+id/header_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/header_img_dec"
android:src="@drawable/right_img" />
</LinearLayout>