0

このアクティビティには線形レイアウト(myLayoutと呼ばれる)があり、その中に2つのボタンがあります。次に、textView の配列を動的に作成し、それらを新しい相対レイアウト (relLayout と呼ばれる) に追加しました。ここで、この relLayout を myLayoutのこれら 2 つのボタンの下に配置します。しかし、方法はわかりませんが、おそらくmyLayout.addView(relLayout, fparams);fparams を定義する方法がわかりません..

何か案は?

4

2 に答える 2

1

myLayoutとを含むレイアウト ページ全体relLayoutを別の にラップしますRelativeLayout。次に、次のようにrelLayoutto 位置に指定します。myLayout

android:layout_below="@id/myLayout_ID"
于 2012-09-22T10:56:19.373 に答える
1

-まず、 L1LinearLayoutという名前のMain Parent layout仮定として、Vertical orientation.

-次に、レイアウトL1としてL2として2 番目LinearLayoutの名前を作成します。child to the parentVertical orientation

-buttonこの子に 2 を配置しますLinearLayout L2.

-という名前のこのLinearLayoutL2 属性を設定しますLayout_weight as 1.

-次に、RelativeLayoutこの LinearLayout L2 の下に配置し、ここで動的に生成しtextViewます....

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" android:layout_weight="1">

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />


        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button" />

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >
    </RelativeLayout>

</LinearLayout>
于 2012-09-22T10:57:51.597 に答える