我的項目文件有XML
,如根xml
。在根xml
我限定Relative layout
像下面如何在相對佈局中動態添加相對佈局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_view">
</RelativeLayout>
我有另一個xml
文件首先是one.xml
和另一個是two.xml
像下面
one.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:id="@+id/two_video_layout">
<TextView
android:id="@+id/two_video_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:singleLine="true"
android:text="Video Title" />
</RelativeLayout>
和另一個佈局是
two.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:id="@+id/two_video_layout">
<Imageview
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
,我們怎樣才能root.xml
添加one.xml
或two.xml
動態與某些條件,以及如何可以訪問one.xml
文件