Reputation: 436
My xml file is like following:
<LinearLayout>
<ScrollView>
<LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
First LinearLayout has android:layout_height="match_parent"
, all others android:layout_height="wrap_content"
. How to create a layout at bottom of screen always in the foreground with an imageview?
Upvotes: 0
Views: 1360
Reputation: 24848
Try this way,hope this will help you to solve your problem with another one alternative.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:adjustViewBounds="true"
android:layout_gravity="bottom|center_horizontal"/>
</FrameLayout>
Upvotes: 0
Reputation: 3783
This is best done with a relative layout. Relative layout elements stack on top of each other unless you position them relative to each other. For instance, if you had two image views and did position them, the second image view would be placed on top of the first one.
Here is an example to get you started:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</ScrollView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:contentDescription="@string/YOUR_CONTENT_DESC"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher"/>
</RelativeLayout>
Upvotes: 1
Reputation: 1
you could set the gravity of the linear layout to bottom.
android:layout_gravity="bottom"
When your creating your XML document order does matter. So for example:
<ImageView/>
<LinearLayout/>
The LinearLayout will be placed in front of the ImageView.
Upvotes: 0