CQM
CQM

Reputation: 44220

Android layout alignment not behaving

This is the result and this is not what is desired. The text should be aligned to the left. the checkbox should be aligned to the right. The extra long text should be slightly squished so that there is room for the radiobutton on the right.

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:layout_margin="10dp"
android:padding="5dp">

<TextView android:id="@+id/itemCaption"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true" 
    android:textSize="13dp"
    android:textColor="#feee"/> 

<RadioButton
    android:id="@+id/itemRadioBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     android:layout_marginRight="5dp"
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    android:layout_toRightOf="@+id/itemCaption"
    android:text="" />

</RelativeLayout>

How do I fix it to display as desired?

Upvotes: 0

Views: 227

Answers (1)

trumpetlicks
trumpetlicks

Reputation: 7065

Your line

android:layout_toRightOf="@+id/itemCaption"

takes precedence over your line

android:layout_alignParentRight="true"

try removing the android:layout_toRightOf="@+id/itemCaption" line!!!

Upvotes: 1

Related Questions