我的项目文件有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
文件