Problem with RelativeLayout when using "fill

I have a Layout (using TableLayout, etc...) which works well. It seems like this: http://i.stack.imgur.com/jLFhA.png

I would like to rewrite it using one RelativeLayout:

<?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="fill_parent"  android:padding="6dip">

<TextView android:id="@+id/textViewTopicTitle"      
android:layout_width="fill_parent" android:layout_height="wrap_content"         android:text="Title" android:background="#880000"></TextView>   

<TextView android:id="@+id/textViewSolution"        
android:layout_width="wrap_content" android:layout_height="wrap_content"        android:layout_below="@id/textViewTopicTitle" android:text="Description...."        android:background="#008800"></TextView>    

<Button android:text="Start" android:id="@+id/buttonTopic"      android:layout_width="wrap_content" android:layout_height="wrap_content"        android:layout_toRightOf="@id/textViewSolution" android:layout_below="@id/textViewTopicTitle"       
android:layout_marginRight="6dip">
</Button> 

</RelativeLayout>

It's not correct because the green TextView not fill as many space as possible.

So I change: android:id="@+id/textViewSolution" android:layout_width=" fill_parent "

But in this case the button is missing!

http://i.stack.imgur.com/ugzeq.png

My question is: is that possible to create such a layout using only RelativeLayout?


尝试下面的XML可能会帮助按钮有点高

<?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="fill_parent"
    android:padding="6dip">
    <TextView
        android:id="@+id/textViewTopicTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:background="#880000"></TextView>
    <TextView
        android:id="@+id/textViewSolution"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/textViewTopicTitle"
        android:text="Description...."
        android:background="#008800"
        android:layout_toLeftOf="@+id/buttonTopic"></TextView>
    <Button
        android:text="Start"
        android:id="@+id/buttonTopic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/textViewTopicTitle"
        android:layout_alignParentRight="true">
    </Button>
</RelativeLayout>

尝试下面的代码

<?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="fill_parent" 
android:padding="6dip"> 

<TextView android:id="@+id/textViewTopicTitle" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Title" 
android:background="#880000"></TextView> 

<Button android:text="Start" 
android:id="@+id/buttonTopic" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_alignParentRight="true"
android:layout_below="@id/textViewTopicTitle" 
android:layout_marginRight="6dip"> 
</Button> 

<TextView android:id="@+id/textViewSolution" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_below="@id/textViewTopicTitle" 
android:layout_toLeftOf="@+id/buttonTopic"
android:text="Description...." 
android:background="#008800"></TextView> 
</RelativeLayout> 

试试这个代码....它的作品

<?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="fill_parent"
    android:padding="6dip">

    <TextView android:id="@+id/textViewTopicTitle"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:text="Title" android:background="#880000"></TextView>
    <TextView android:id="@+id/textViewSolution"
        android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="160dip"
        android:layout_below="@id/textViewTopicTitle" android:text="Description...."
        android:background="#008800"></TextView>
    <Button android:text="Start" android:id="@+id/buttonTopic"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_toRightOf="@id/textViewSolution" android:layout_below="@id/textViewTopicTitle"
        android:layout_marginRight="6dip"></Button>
</RelativeLayout>
链接地址: http://www.djcxy.com/p/16646.html

上一篇: MapView不支持布局

下一篇: 使用“fill”时出现RelativeLayout问题