tags:

views:

42

answers:

2

How do you align views relative to the "middle" part of another view?

I think it is best explained with a pic of the UI I'm trying to create in android.

alt text

A: 

This can be done with a RelativeLayout. With the property android:layout_alignBaseline a view can be aligned to another views baseline.

I would use layout_alignParentBottom to align the arrow button at the bottom of the view and then use layout_toRightOf and alignBaselineto get the send button to be displayed in the way it is shown in the image.

Janusz
could you give a example or code thanks
pengwang
A: 

i usedthe follows code,but it still has some shortcomings: you should modify the value:

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

android:layout_gravity="center_horizontal|center_vertical"
>
<EditText 
    android:id="@+id/bullet"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:paddingRight="4dip"
    android:includeFontPadding="false"
    android:lines="4"
    android:text="hidhidihfidhfdifhdifhdifhidhfidf" />
<ImageView
    android:id="@+id/icon"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="#ffff00"
    android:src="@drawable/icon"
    android:layout_alignTop="@id/bullet"

     android:layout_marginLeft="50dip" />

  <ImageView
    android:id="@+id/icon1"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"

    android:background="#ff00ff"
    android:layout_alignBottom="@id/bullet"

    android:layout_marginLeft="100dip"
    android:src="@drawable/star_logo" />

  </RelativeLayout>
pengwang