![](/img/trans.png)
[英]Android: Dynamically add TextView on a TableLayout with fixed Width
[英]Android TableLayout question: get a fixed-width right column?
( 编辑:我比以前更进一步 )
我一直在尝试获得一个简单的2列TableLayout,在该列的左列中有一个LinearLayout,我动态向其中添加了填充水平空间的元素,除了固定的100px右列。
如果LinearLayout包含多个元素,这就是我到目前为止可以使用的内容。 如果仅包含一个元素,则将右列推出到屏幕的右边
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@layout/main">
<TableLayout android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.4"
android:orientation="vertical"></LinearLayout>
<com.epaga.ArcDrawableView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right" android:layout_weight="0.1" >
</com.epaga.ArcDrawableView>
</TableRow>
</TableLayout>
</ScrollView>
我尝试过的事情:
android:layout_width="150px"
stretchcolumns
设置更改为0。 layout_width
更改为fill_parent(将右列从屏幕上推出)或wrap_content(折叠左列) 有什么想法吗?
有什么想法吗?
首先,为什么要使用TableLayout
? 为什么不只使用嵌套的LinearLayouts
? 您已经决定不关心TableLayout
的主要用途-列大小的自动计算-因为您正在尝试自己修复列大小。
其次,您可以使用普通的窗口小部件而不是自定义的View
类来使其正常工作吗? 您的问题可能是由于您自定义的View
-我将首先使用您希望使用普通小部件的方式来工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.