1

下の画像に示すように、プログラムで1 つの全画面 Android アクティビティを作成する必要があります。画面がどのように見えるか

2 つのボタンは画面の下部に残る必要があります。ダミー コンテンツは、さまざまなコンポーネント (テキストビュー、ラジオ ボタン、チェックボックスなど) で構成され、動的に入力されます。

これは私がこれまでに持っているコードです:

        //Main Layout
    FrameLayout lLayout = new FrameLayout(this);
    lLayout.setBackgroundColor(Color.parseColor("#0099cc"));
    lLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
    //Navigation layout
    LinearLayout l = new LinearLayout(this, null, R.style.ButtonBar);
    LayoutParams bottomLayout = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);
    l.setLayoutParams(bottomLayout);
    l.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
    l.setBackgroundColor(Color.parseColor("#66000000"));
    l.setOrientation(LinearLayout.HORIZONTAL);


    LayoutParams buttLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //previous section button
    previousButton = new Button(this);
    previousButton.setLayoutParams(buttLayout);
    previousButton.setText("Previous section");
    previousButton.setOnClickListener(this);
    l.addView(previousButton);
    //next section button
    Button nextButton = new Button(this);
    nextButton.setLayoutParams(buttLayout);
    nextButton.setText("Next section");
    nextButton.setOnClickListener(this);
    l.addView(nextButton);

    //add components
    TextView tView = new TextView(this);
    tView.setText("Dummy text");
    tView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
    lLayout.addView(tView);
    lLayout.addView(l);
    setContentView(lLayout);

コードが生成するものは次のとおりです。 ここに画像の説明を入力

意図したとおりに機能しない点がいくつかあります。 1. ボタンが上部にあり、下部にありません。2. ボタンがきれいに広がりません。 3. テストとして追加した TextView がボタンの後ろに表示されます。画面にはさまざまなウィジェットがあり、それらが 1 つの画面よりも大きいと予想されます。スクロールオプションが欲しいのですが、これらのウィジェットはすべて、画面の下部にあるはずの 2 つのボタンの後ろに表示されません。

4

2 に答える 2