Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RelativeLayout与父级的高度不匹配_Android_Listview_Android Relativelayout - Fatal编程技术网

Android RelativeLayout与父级的高度不匹配

Android RelativeLayout与父级的高度不匹配,android,listview,android-relativelayout,Android,Listview,Android Relativelayout,主布局内的relativelayout在设备上显示时不会填充父级高度。事实上,我希望左侧的黄色布局垂直填充行。 以下是xml代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/verses_relativeLayout" android:layout_width

主布局内的relativelayout在设备上显示时不会填充父级高度。事实上,我希望左侧的黄色布局垂直填充行。

以下是xml代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/verses_relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.ad.holyquran.extra.TextViewEx
    android:id="@+id/textView_Verse"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@+id/versesRelativeLayout"
    android:gravity="right"
    android:layout_marginTop="-15dp"
    android:paddingBottom="5dp"
    android:paddingRight="5dp"
    android:text="Text"
    android:textSize="@dimen/versesTextSize"
    android:textColor="#ff000000" />

<TextView
    android:id="@+id/textView_VerseTranslation"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/textView_Verse"
    android:paddingBottom="5dp"
    android:gravity="fill_horizontal"
    android:layout_centerHorizontal="true"
    android:layout_toRightOf="@+id/versesRelativeLayout"
    android:paddingRight="5dp"
    android:paddingLeft="5dp"
    android:paddingTop="5dp"
    android:text="Text Text Text Text Text Text"
    android:textSize="20sp" />

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:id="@+id/versesRelativeLayout"
    android:layout_alignParentLeft="true"
    android:background="#fff3f27f">

    <RelativeLayout
        android:id="@+id/verseNumberIcRL"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/versesImageView"
            android:layout_alignParentTop="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/verse_number_ic" />

        <TextView
            android:id="@+id/textView_verseNumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/versesImageView"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="280"
            android:paddingBottom="28dp"
            android:textSize="14sp"
            android:textColor="#ff000000" />
    </RelativeLayout>
</RelativeLayout>
感谢阅读。

如果您删除该行

android:layout_-toRightOf=@+id/versesRelativeLayout

它将停止在右边。如果您需要黄色作为背景,则在主布局中(第一个相对位置),使用 android:background=@drawable\image

您可能需要将所有其他元素放入主RelativeLayout中。 希望这有帮助。
我看不到主RelativeLayout的结束标记。

只需在layout与RelativeLayout中添加标记即可:

android:layout_alignBottom="@+id/textView_VerseTranslation"

<RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/versesRelativeLayout"
            android:layout_alignParentLeft="true"
            android:background="#fff3f27f"
            android:layout_alignParentTop="false"
            android:layout_alignParentBottom="false"
            android:layout_alignBottom="@+id/textView_VerseTranslation"
            >

我刚试过你的xml代码,布局很高。。尝试删除第二个RelativeLayout ID=verseNumberIcRL我认为这是不必要的。。为什么自定义视图TextViewEx设置为layout_marginTop=-15dp?这可能是导致问题的原因,因为我还有两个类似于verseNumberIcRL的相对布局。布局_marginTop=-15dp是因为在设置字体后,文本将从现在的位置向下移动15dp。这只会使布局与文本视图相对翻译对齐,顶部再次为空。