我有一个简单的问题...我正在尝试为Android制作小型测试应用程序只是为了看看它能做什么......所以..在启动时将android的textview.text设置为来自共享首选项的一些文本并增加文本视图大小垂直..我无法理解为什么..我正在使用tableview与每行中的textview行..
xml代码如下所示:
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView
android:id="@+id/tv1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:layout_weight="5.1"
android:background="#F8F8FF"
android:gravity="fill_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textSize="10sp"
android:textStyle="normal" />
</TableRow>
无论如何都要阻止textview调整大小?或者有一些我错过的属性..?
由于
答案 0 :(得分:2)
android:layout_height="wrap_content"
使用&#34; layout_weight&#34;更改为修复高度或某个相对高度。
如果你说android包装到内容,行将增加/减少以适合他的内容。
编辑:我看到你的layout_weight,但你有1,我想你不知道如何使用它。重量用这个重量来表示宽度和高度,所以想想,你有5行,所以如果1是总重量的1/5 => 0.2将是你的每排重量。 对于重量将适用,您需要说明哪个尺寸是基于重量。 所以你需要把这个
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2" >
您可以在这里阅读更多内容: http://developer.android.com/guide/topics/ui/layout/linear.html