I need a screen that is filled with an image as background and three buttons floating over the image. I created this fine in xml and in vertical orientation it does what I want. However in landscape it doesnt so I have tried to add a scrollview and am getting very confused as to how to combine these elements correctly. After various tries I reached the stage shown below
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/home_container"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:src="@drawable/alert"
android:layout_height="fill_parent" android:layout_width="fill_parent"
android:scaleType="fitCenter" android:clickable="true"
android:enabled="true" />
<LinearLayout android:layout_width="fill_parent"
android:paddingBottom="25px" android:paddingLeft="25px"
android:orientation="vertical" android:paddingTop="90px" android:id="@+id/toplinear"
android:layout_height="fill_parent" android:paddingRight="25px"
android:gravity="top">
<Button android:layout_width="fill_parent" android:textSize="20dp"
android:id="@+id/startprogrambutton" android:paddingBottom="12dp"
android:text="@string/text1" android:layout_height="wrap_content"
android:paddingTop="12dp"></Button>
<Button android:layout_width="fill_parent" android:textSize="20dp"
android:id="@+id/button1" android:paddingBottom="12dp"
android:layout_marginTop="10dp" android:background="@drawable/webview_buttons"
android:text="@string/text2" android:layout_height="wrap_content"
android:paddingTop="12dp"></Button>
<Button android:layout_width="fill_parent" android:textSize="20dp"
android:id="@+id/button2" android:paddingBottom="12dp"
android:layout_marginTop="10dp" android:background="@drawable/webview_buttons"
android:text="@string/text3" android:layout_height="wrap_content"
android:paddingTop="12dp"></Button>
<Button android:layout_width="fill_parent" android:textSize="20dp"
android:id="@+id/button3" android:paddingBottom="12dp"
android:layout_marginTop="10dp" android:background="@drawable/webview_buttons"
android:text="@string/text4" android:layout_height="wrap_content"
android:paddingTop="12dp"></Button>
</LinearLayout>
Now it errors with scrollview can only contain one child. Is there some way to rearrange so that I can have my image and the floating buttons all scroll together?
put both
ImageViewandLinearLayoutin another VerticalLinearLayout. This solves your scrollView child problem.Why don’t you give image as background for linearLayout with buttons, it will serve your purpose.