Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.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 文本视图高度与父对象/填充父对象不匹配_Android_Android Layout_Layout_Textview_Fill Parent - Fatal编程技术网

Android 文本视图高度与父对象/填充父对象不匹配

Android 文本视图高度与父对象/填充父对象不匹配,android,android-layout,layout,textview,fill-parent,Android,Android Layout,Layout,Textview,Fill Parent,我有一个简单的文本视图,只有一行。 我想将高度设置为匹配\u parent/fill\u parent,但Android的行为是仅包装\u内容 有没有办法强制TextView采用所有高度 Tkx 编辑: 这就是我得到的: 和我的布局: <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView

我有一个简单的文本视图,只有一行。 我想将高度设置为匹配\u parent/fill\u parent,但Android的行为是仅包装\u内容

有没有办法强制TextView采用所有高度

Tkx

编辑:

这就是我得到的:

和我的布局:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

<TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:paddingLeft="13dp"
        android:paddingRight="3dp"
        android:textColor="@android:color/white"
        android:textStyle="bold" />

        [...]

</RelativeLayout>

[...]

对于
TextView
父宽度,您可以使用
wrap\u content

您可以将文本视图高度设置为匹配父项/填充父项。并根据需要更改文本视图的重力所有其他属性

如果这对你来说还不够,那么让我知道你到底想做什么

编辑:

根据你新编辑的代码,我对你的代码进行了修改

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" 
android:layout_width="match_parent">
<TextView android:id="@+id/date" 
    android:layout_width="wrap_content"
    android:layout_height="match_parent" 
    android:gravity="center"
    android:paddingLeft="13dp" 
    android:paddingRight="3dp"
    android:textStyle="bold" 
    android:textColor="#ffffff" 
    android:text="dateText"/>
</RelativeLayout>

现在它在整个屏幕的中央垂直位置显示文本视图


试试这个代码。它起作用了。更改您的RelativeLayout文本视图

也有同样的问题,您是否最终解决了其他问题或此方案?