相对布局的问题

时间:2011-04-27 10:37:57

标签: android

我正在尝试放置两个组件。第一个(Edittext)应该扩展到下一个组件(提交按钮)。我该怎么做呢?我的XML如下...... 问题是Edittext扩展为填充屏幕并隐藏按钮:

<?xml version="1.0" encoding="utf-8"?>

<EditText
            android:id="@+id/etFeedBackText"
            android:hint="What do you think of this app? Any comments or suggestions?"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignBottom="@id/btnFeedBackSubmit"              
            >       
</EditText>

<Button
    android:id="@+id/btnFeedBackSubmit"
    android:text="Submit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/etFeedBackText"
    android:layout_alignParentBottom="true"
    >

5 个答案:

答案 0 :(得分:0)

将Button声明放在EditText上方,并在EditText属性中设置: android:layout_above="@id/btnFeedBackSubmit"

答案 1 :(得分:0)

删除此行

 android:layout_alignBottom="@id/btnFeedBackSubmit"  

答案 2 :(得分:0)

试试这个

<EditText
            android:id="@+id/etFeedBackText"
            android:hint="What do you think of this app? Any comments or suggestions?"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/btnFeedBackSubmit"              
            >       
</EditText>

<Button
    android:id="@+id/btnFeedBackSubmit"
    android:text="Submit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    >

答案 3 :(得分:0)

<EditText
            android:id="@+id/etFeedBackText"
            android:hint="What do you think of this app? Any comments or suggestions?"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
     XXXXXXXX remove this      android:layout_alignBottom="@id/btnFeedBackSubmit"   
     XXXXXXXX write this       android:layout_above="@id/btnFeedBackSubmit"           
            >       
</EditText>

答案 4 :(得分:0)

<?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">
<Button
    android:id="@+id/btnFeedBackSubmit"
    android:text="Submit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" />
<EditText
     android:id="@+id/etFeedBackText"
     android:hint="What do you think of this app? Any comments or suggestions?"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_above="@id/btnFeedBackSubmit" />       
</RelativeLayout>