2011-03-31 67 views
0
<LinearLayout android:orientation="vertical" android:layout_width="wrap_content" 
     android:id="@+id/contentLayout" android:layout_height="wrap_content" 
     android:background="@drawable/text_box_middle_imanage" > 

<TextView android:text="header text here" android:layout_width="match_parent" android:gravity="center" android:layout_height="wrap_content"/> 


<TextView android:text="large content Text here" android:layout_width="match_parent" android:layout_height="wrap_content"/> 


</LinearLayout> 

我想为单个背景设置多个textViews。所以我把所有的文本视图放在一个linearLayout中,并在这个线性布局中添加背景。有一个标题文本和一些内容文本被组织成多个TextViews。我面临的问题是:当我在第二个textView中放大文本时,它正在扩展布局,但我希望背景图像应该固定不应该扩大添加文本。所有的文本都应该只存在于后台边界。我知道这不是很棘手,但我是Android新手,所以面临这个问题。修复TextView背景问题

我知道一种给线宽布局固定宽度(px或dp)的方法,但它不是一个好方法(如果我是正确的)。有没有其他方法?

这里是屏幕截图,你能弄清楚这个问题:http://postimage.org/image/1a8d1g538/

+0

你想有背景图像的每个TextView的或单一的背景并且你重叠了所有的TextView? – 2011-03-31 07:22:29

+0

是一个单一的背景,并且你重叠了所有的TextViews。 – 2011-03-31 07:25:56

+0

你可以把一些示例屏幕截图? – 2011-03-31 07:28:38

回答

1

试试这个:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:id="@+id/contentLayout" android:layout_height="fill_parent" android:background="@drawable/untitled" > 
<TextView android:text="header text here" android:layout_width="fill_parent" `android:gravity="center" android:layout_height="wrap_content"/> 
<TextView android:text="large content Text here" android:layout_width="fill_parent" android:layout_height="wrap_content"/> 
</LinearLayout> 

`

+0

请参阅屏幕截图 – 2011-03-31 07:45:41

+0

Hav你试过上面的代码? – 2011-03-31 07:48:05

+0

你已经给android:layout_width =“fill_parent”,这使得布局占据屏幕的全部宽度,但是在我的问题中,我希望宽度完全是背景图像的大小,请看屏幕截图 – 2011-03-31 07:53:13