使用textview自动调整线性布局

时间:2014-05-16 23:49:54

标签: android android-layout

我正在寻找一种方法让linearlayout适合我的整个textview, 所以我的数据库中有很多单词在textview

上显示

这是我的布局设计:

首先,textview显示数据库中没有太多单词的一些单词。

enter image description here

这就是在textview

中显示了这么多单词

enter image description here

2 个答案:

答案 0 :(得分:3)

只为每个wrap_content

添加heights
TextView1 -> layout_height="wrap_content"
TextView2 -> layout_height="wrap_content"
LinearLayout-> layout_height="wrap_content"

wrap_content用于根据内容自动调整布局大小。

答案 1 :(得分:0)

您是否在询问如何获取多个文本视图以占用整个布局,或者在布局上显示数据库中的多个单词?

如果您只想要一两个文字视图,请查看linear layout weight property

android:weightSum 
//defines the maximum weight sum.

对于每个文本视图,根据您希望它占用多少布局,设置其

android:weight 

属性

如果您要查找多个textview,我建议您只使用ListView