2012-08-02 79 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