【发布时间】:2012-12-21 15:12:09
【问题描述】:
我想在我的应用程序中自定义 TableRow - 更改它的高度以便我可以在其中放置两行按钮。我无法在 UI 设计器中实现它。那么问题来了——我如何以编程方式在 XML 或 Java 代码中执行此操作?
【问题讨论】:
标签: java android tablerow android-tablelayout
我想在我的应用程序中自定义 TableRow - 更改它的高度以便我可以在其中放置两行按钮。我无法在 UI 设计器中实现它。那么问题来了——我如何以编程方式在 XML 或 Java 代码中执行此操作?
【问题讨论】:
标签: java android tablerow android-tablelayout
不完全确定您想要什么,但这里是您如何在一个 TableRow 中获得 Buttons 的“行”。做类似的事情,看看你在说什么。
我在TableRow 中添加了一个LinearLayout,即vertical orientation,然后将Buttons 包装在另一个LinearLayout 中,即horizontal orientation。
<TableRow>
<LinearLayout
android:id="@+id/layout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/layout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ABCDE" />
<Button
android:id="@+id/button2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A" />
<Button
android:id="@+id/button3"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ABC" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ABCDE" />
<Button
android:id="@+id/button2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A" />
<Button
android:id="@+id/button3"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="ABC" />
</LinearLayout>
</LinearLayout>
</TableRow>
【讨论】: