私はmain_layout.xml
ルートレイアウトとして持っていますが、それがRelativeLayout
またはLinearLayout
. そして、そのルート レイアウトには独自の異なるレイアウトがあります。基本的には次のようになります。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/default_background" >
<RelativeLayout
android:id="@+id/panel_bar">
<!-- -->
</RelativeLayout>
<RelativeLayout
android:id="@+id/other_bar">
</RelativeLayout>
<RelativeLayout
android:id="@+id/main_bar">
<Button id="@+id/change_button" />
</RelativeLayout>
</RelativeLayout>
クリックしchange_button
たら、別のレイアウトに変更したいpanel_bar
、としましょうanother_layout
。ちなみに、another_layout
別ファイルの既存のレイアウトです。両方とも (panel_bar
とanother_layout
) 同じ身長と体重です。私はそれらを切り替えたいだけです。
私の考えは正しくないかもしれません。別のアプローチが必要かもしれません。私はあなたの提案について本当に興味があります. どんな助けでも素晴らしいでしょう。