Android TextView位于RelativeLayout中按钮的后面

Android TextView位于RelativeLayout中按钮的后面,android,xml,android-layout,xamarin,Android,Xml,Android Layout,Xamarin,我有一个RelativeLayout,其中有一个文本视图和一个按钮。按钮有一个属性android:layout\u alignParentBottom=“true”,可以。问题是文本视图:如果文本很大,它就在按钮后面 我需要的是可调整大小的TextView,它不会出现在按钮后面。如果文本较大,我们只能看到与顶部和按钮之间的大小相匹配的文本部分。 类似于两行,其中第2行(带按钮)具有固定高度,第1行可调整大小。 有人知道怎么做吗?添加: android:layout_above="@+id/

我有一个RelativeLayout,其中有一个文本视图和一个按钮。按钮有一个属性
android:layout\u alignParentBottom=“true”
,可以。问题是文本视图:如果文本很大,它就在按钮后面


我需要的是可调整大小的TextView,它不会出现在按钮后面。如果文本较大,我们只能看到与顶部和按钮之间的大小相匹配的文本部分。 类似于两行,其中第2行(带按钮)具有固定高度,第1行可调整大小。 有人知道怎么做吗?

添加:

android:layout_above="@+id/button1"
您的文本视图,如:

<RelativeLayout android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/absoluteLayout1">
    <TextView
        android:text="Long long string"
        android:textSize="16dp"
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:textColor="#d9e700"
        android:id="@+id/text"
        android:layout_above="@+id/button1"
        android:layout_marginBottom="12.5dp" />
    <Button
        android:text="Button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:id="@+id/button1" />
</RelativeLayout>

您需要对齐按钮上方的文本视图。使用上面的布局属性。 下面是一个例子

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/absoluteLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="25px"
android:minWidth="25px">

<TextView
    android:id="@+id/text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/button1"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="12.5dp"
    android:text="Long long string"
    android:textColor="#d9e700"
    android:textSize="16dp" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="Button" />

1)在文本视图中添加android:layout_=“@id/button1”
2) 将您的文本视图放在按钮下方,这样您就可以将按钮引用到您的文本视图中。

<RelativeLayout
    android:id="@+id/absoluteLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="25px"
    android:minWidth="25px">

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Button" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/button1"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="12.5dp"
        android:text="Long long string"
        android:textColor="#d9e700"
        android:textSize="16dp" />
</RelativeLayout>


就一行,天哪。。。非常感谢,这真的解决了我的问题!在api 18中工作。上面没有布局选项。谢谢您的回复!
<RelativeLayout
    android:id="@+id/absoluteLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="25px"
    android:minWidth="25px">

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Button" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/button1"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="12.5dp"
        android:text="Long long string"
        android:textColor="#d9e700"
        android:textSize="16dp" />
</RelativeLayout>