【问题标题】:How to change TableRow height in Android?如何在 Android 中更改 TableRow 的高度?
【发布时间】:2012-12-21 15:12:09
【问题描述】:

我想在我的应用程序中自定义 TableRow - 更改它的高度以便我可以在其中放置两行按钮。我无法在 UI 设计器中实现它。那么问题来了——我如何以编程方式在 XML 或 Java 代码中执行此操作?

【问题讨论】:

    标签: java android tablerow android-tablelayout


    【解决方案1】:

    不完全确定您想要什么,但这里是您如何在一个 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-12
      • 2011-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      相关资源
      最近更新 更多