简体   繁体   中英

Is is possible to view two xml at the same time in Android?

Is is possible to view two xml at the same time in Android? Suppose xml1 contains an ImageView and xml2 contains another ImageView. Likes to view both images at the same time sharing half of the total window size

Try using the include feature: http://developer.android.com/resources/articles/layout-tricks-reuse.html

Here's an example that might work for you (make sure you put these inside of a root layout tag, like LinearLayout , as if they were any other View items):

<include android:id="@+id/image1" layout="@layout/xml1" />
<include android:id="@+id/image2" layout="@layout/xml2" />

The id s can be whatever you want, but the layout must match the name of the separate XML file in your project.

As far as making each one take up exactly half the screen at the same time, you'll want to try setting the weight for each one to the same value. See the example here: Assign width to half available screen width declaratively

So like this:

<include android:id="@+id/image1" layout="@layout/xml1" android:layout_weight="1" />
<include android:id="@+id/image2" layout="@layout/xml2" android:layout_weight="1" />

You might also need to add android:layout_height or layout_width (depending on whether your layout is vertical or horizontal) set to fill_parent to get your desired effect.

我们可以在一个窗口中看到两个xml文件。但是我们一次只修改了一个xml文件,在清单文件的Activity标签中使用下面的poperty

 android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM