Reputation: 11649
Sorry I am new in Android
Because of my large contents I am going to create a ScrollView
. In this way, I have created some parts of my content in 1 file (let's call it FirstLayout.xml) and the other part SeconedLayout.xml. Now I am going to call both of them in a single XML file.(Parent.xml)
But the problem is, I don't know, how should I call them in my ScrollView?
here is the code
FirstLayout.xml
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
.
.
.
</AbsoluteLayout>
SeconedLayout.xml is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
...
</LinearLayout>
Parent.xml
visible
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<!-- Call FirstLayout -->
<!-- Call SecondLayout -->
</ScrollView>
Upvotes: 2
Views: 1457
Reputation: 2158
you can include layout like
<include layout="@layout/FirstLayout" />
<include layout="@layout/SeconedLayout" />
so your layout should be like
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include layout="@layout/FirstLayout" />
<include layout="@layout/SeconedLayout" />
</LinearLayout>
</ScrollView>
Upvotes: 1
Reputation: 467
try just to use the include tag like that :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<include layout="@layout/FirstLayout" />
<include layout="@layout/SeconedLayout" />
</ScrollView>
But for better performance, use the tag, that helps eliminate redundant view groups in your view hierarchy when including one layout within another. Get a look here.
Upvotes: 0
Reputation: 1814
You should use include tag:
<include
layout="@layout/SeconedLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Upvotes: 2