2012-08-02 82 views
3

我有一个简单的TextView与单线。 我想设置高度为match_parent/fill_parent,但Android的行为仅限于wrap_content。TextView高度不匹配_parent/fill_parent

有没有办法强制将TextView的通吃高度?

TKX

编辑:

这就是我得到:

enter image description here 和我的布局:

<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> 
+0

有同样的问题,你最终与其他或此方案解决了什么? – htafoya 2013-06-25 21:53:53

回答

0

对于TextView父母宽度,你可以使用wrap_content

0

您可以将TextView高度设置为match_parent/fill_parent。并根据您的要求改变重力的TextView的所有其他财产

如果这不是suffiecient你,然后让我知道你想要做什么。

编辑:

按新编辑的代码我曾在你的代码。

<?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> 

现在它示出了在整个屏幕的central_vertical位置的TextView

试试这个代码。它的工作。更改RelativeLayout的的TextView我这些做。

+0

我编辑了我的信息。您的解决方案不起作用 – g123k 2012-08-02 10:41:02

+0

我的编辑后对您有用吗? – Debarati 2012-08-02 13:21:33