Android 使用“RelativeLayout”时出现问题;填写“家长”;

Android 使用“RelativeLayout”时出现问题;填写“家长”;,android,Android,我有一个布局(使用TableLayout等),它工作得很好。似乎是这样的: 我想用一个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_

我有一个布局(使用TableLayout等),它工作得很好。似乎是这样的:

我想用一个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>

这是不正确的,因为绿色文本视图没有尽可能多地填充空间

所以我改变了: android:id=“@+id/textViewSolution”android:layout_width=“fill_parent

但在这种情况下,按钮不见了


我的问题是:是否可以仅使用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>

试试下面的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>