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
2 Answers
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.

- 1
- 1

- 868
- 2
- 11
- 26
we can see both xml files in one window .But at a time we modified only one xml file only, Use the below poperty in Activity tag in manifest file
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

- 21,723
- 16
- 55
- 88