简体   繁体   English

如何在Android中更改TableRow高度?

[英]How to change TableRow height in Android?

I want to customize TableRow in my app - change it's height in order i can place two rows of buttons in it. 我想在我的应用程序中自定义TableRow - 更改它的高度,以便我可以在其中放置两行按钮。 I can't implement it in UI designer. 我无法在UI设计器中实现它。 So the question - how can I do this programmaticaly in XML or Java code? 所以问题是 - 如何在XML或Java代码中实现这一程序化?

Not exactly sure what you are wanting, but here is how you can get "rows" of Buttons in one TableRow . 不完全确定你想要什么,但这里是如何在一个TableRow获得Buttons “行”。 Do something similar to this and see if that is what you are talking about. 做类似的事情,看看你是否正在谈论这个问题。

I added a LinearLayout to the TableRow that is vertical orientation and then wrapper the Buttons in another LinearLayout that is horizontal orientation . 我将一个LinearLayout添加到vertical orientationTableRow ,然后将Buttons包装在另一个horizontal orientation LinearLayout中。

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM