I have to split my layout in two parts:
the upper part shall be without ScrollView (in order to draw horizontal and vertical lines. I have got problems to draw vertical Lines, when the complete Layout have got a ScrollView)
the lower part shall be with ScrollView (in order to scroll through different Elements)
This picture shall explain, how it should look like:
My layoutfile looks like that:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawingLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<com.unitnode.Drawing
android:id="#+id/drawingView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageButton
android:id="#+id/eraseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rubber" />
<ImageButton
android:id="#+id/undoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/undo" />
<ImageButton
android:id="#+id/neuerZeichenButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/newbutton" />
<ImageButton
android:id="#+id/saveZeichenView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/savebutton" />
<View
android:id="#+id/linie1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/hintergrundfarbeFullZeichenView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hintergrundfarbe" />
<Button
android:id="#+id/hintergrundfarbeFullButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/schwarzbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roterbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gelberbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/weiserbuttonshape" />
<ImageButton
android:id="#+id/hintergrundfarbeFullButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/farbpallete" />
<View
android:id="#+id/linie2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/strichfarbeFullText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strichfarbe" />
<Button
android:id="#+id/strichfarbeFullButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/schwarzbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roterbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gelberbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/weiserbuttonshape" />
<ImageButton
android:id="#+id/strichfarbeFullButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/farbpallete" />
<View
android:id="#+id/linie3"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/strichdickeTextFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strichdicke" />
<SeekBar
android:id="#+id/strokeSeekbarFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/strichdickeTextMinFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0dp" />
<View
android:id="#+id/linie4"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/opacityText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Durchsichtigkeit: " />
<TextView
android:id="#+id/opacityMinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0% " />
<SeekBar
android:id="#+id/opacitySeekbarFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:id="#+id/unschaerfeFilterCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unschärfefilter AN/AUS"
android:textSize="12sp" />
<TextView
android:id="#+id/radiusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radius:" />
<TextView
android:id="#+id/radiusMinTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1dp" />
<SeekBar
android:id="#+id/unschaerfeSeekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/unschaerfeCheckBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Inner"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Normal"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Outer"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solid"
android:textSize="10sp" />
<TextView
android:id="#+id/formenText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Formen: " />
<ImageButton
android:id="#+id/kreisFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/kreis" />
the Element com.unitnode.Drawing is my Drawing View (the upper part).
I tried different things without success:
defined 1 ScrollView over whole page and tried to limit the height of it -> vertical lines can't be drawn
changed layout_height to wrap_content -> no change. I defined it to com.unitnode.Drawing too, but the app shut down because of onSizeChanged( ) method (width and height must > 0)
I tried to insert a ScrollView element after the drawing View. And added for this another Framelayout -> can't handle that
If you need Java code, please let me know.
Please help me to change my code, so that the layout consists of two part (shown in picture)
EDIT: I changed my xml file to this (used FrameLayout because of correct formatting):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/drawingLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.unitnode.Drawing
android:id="#+id/drawingView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/eraseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rubber" />
<ImageButton
android:id="#+id/undoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/undo" />
<ImageButton
android:id="#+id/neuerZeichenButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/newbutton" />
<ImageButton
android:id="#+id/saveZeichenView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/savebutton" />
<View
android:id="#+id/linie1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/hintergrundfarbeFullZeichenView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hintergrundfarbe" />
<Button
android:id="#+id/hintergrundfarbeFullButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/schwarzbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roterbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gelberbuttonshape" />
<Button
android:id="#+id/hintergrundfarbeFullButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/weiserbuttonshape" />
<ImageButton
android:id="#+id/hintergrundfarbeFullButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/farbpallete" />
<View
android:id="#+id/linie2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/strichfarbeFullText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strichfarbe" />
<Button
android:id="#+id/strichfarbeFullButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/schwarzbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roterbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gelberbuttonshape" />
<Button
android:id="#+id/strichfarbeFullButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/weiserbuttonshape" />
<ImageButton
android:id="#+id/strichfarbeFullButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/farbpallete" />
<View
android:id="#+id/linie3"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/strichdickeTextFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Strichdicke" />
<SeekBar
android:id="#+id/strokeSeekbarFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/strichdickeTextMinFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0dp" />
<View
android:id="#+id/linie4"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#000000" />
<TextView
android:id="#+id/opacityText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Durchsichtigkeit: " />
<TextView
android:id="#+id/opacityMinText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0% " />
<SeekBar
android:id="#+id/opacitySeekbarFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox
android:id="#+id/unschaerfeFilterCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unschärfefilter AN/AUS"
android:textSize="12sp" />
<TextView
android:id="#+id/radiusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radius:" />
<TextView
android:id="#+id/radiusMinTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1dp" />
<SeekBar
android:id="#+id/unschaerfeSeekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="#+id/unschaerfeCheckBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Inner"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Normal"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Outer"
android:textSize="10sp" />
<RadioButton
android:id="#+id/unschaerfeCheckBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solid"
android:textSize="10sp" />
<TextView
android:id="#+id/formenText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Formen: " />
<ImageButton
android:id="#+id/kreisFull"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/kreis" />
</FrameLayout>
</ScrollView>
</FrameLayout>
You should try your layout as below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawingLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/drawingContainerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Need to add your drawing view-->
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<!-- Bottom views that are scrollable -->
</LinearLayout>
</ScrollView>
</LinearLayout>
It seems, that the ScrollView is located on Top of the whole underlaying FrameLayout. That's the reason, because I can't draw anything. When I set the Visibilty of the ScrollView to invisible than I am able to draw again. But I can't see the elements anymore certainly.
Is there an other way than changing the visibility? Is it possible to bring the underlaying FrameLayout to the front and how could I achieve that?
Related
I have an app where the scrolView (relative layout inside it) take up the whole screen (fill_parent). But instead of ending at the end of the phone i would like to have a fragment at the bottom and have the ScrollView layout to stop at the top of the fragment. I think it probably has to do with the height but can't really figure out the code. Please look at my imgur image to get my idea. Imgur_Image, press here
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"><![CDATA[
tools:context="c.timno.smsgsm.MainActivity">
]]>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="status?"
android:id="#+id/skicka"
android:hint="Status?"
android:layout_marginTop="38dp"
android:layout_below="#+id/buttonanvandare"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="på"
android:id="#+id/skickaaon"
android:layout_marginEnd="36dp"
android:layout_below="#+id/textViewlarm"
android:layout_alignEnd="#+id/skicka" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Av"
android:id="#+id/skickaaoff"
android:layout_below="#+id/textViewlarm"
android:layout_toEndOf="#+id/skickarela1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 1"
android:id="#+id/skickarela1"
android:layout_alignTop="#+id/skickarela2"
android:layout_alignStart="#+id/skickaaon" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 2"
android:id="#+id/skickarela2"
android:layout_below="#+id/textView"
android:layout_toEndOf="#+id/skickarela1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aktivera"
android:gravity="center"
android:textSize="29dp"
android:id="#+id/textView"
android:layout_below="#+id/skickaaon"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Larm"
android:textSize="29dp"
android:id="#+id/textViewlarm"
android:layout_below="#+id/skicka"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Avaktivera"
android:textSize="29dp"
android:id="#+id/textView3"
android:autoText="false"
android:layout_below="#+id/textView"
android:layout_alignEnd="#+id/buttoninstallator"
android:layout_marginTop="46dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 1"
android:id="#+id/skickatrela1off"
android:layout_below="#+id/textView3"
android:layout_toStartOf="#+id/skickatrela2off" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Relä 2"
android:id="#+id/skickatrela2off"
android:layout_alignTop="#+id/skickatrela1off"
android:layout_alignStart="#+id/skickarela2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Användare"
android:id="#+id/buttonanvandare"
android:layout_alignParentStart="true"
android:layout_toStartOf="#+id/skickaaoff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Installation"
android:id="#+id/buttoninstallator"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/buttonanvandare" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="status?"
android:id="#+id/statustxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="aon"
android:id="#+id/aon"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="aoff"
android:id="#+id/aoff"
android:layout_alignParentStart="true"
android:layout_below="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="on*1*"
android:id="#+id/rela1txxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="On*2*"
android:id="#+id/rela2onn"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="off*2*"
android:id="#+id/rela2offtxt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="off*1*"
android:id="#+id/offrela1txt"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Värmestyrning"
android:textSize="33dp"
android:id="#+id/textView8"
android:layout_below="#+id/skickatrela1off"
android:layout_marginTop="25dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Komfortvärme"
android:textSize="29dp"
android:id="#+id/textView9"
android:layout_below="#+id/textView8" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heaton"
android:id="#+id/btnHeaton"
android:layout_below="#+id/textView9"
android:layout_alignEnd="#+id/skickatrela1off" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heatoff"
android:id="#+id/btnHeatoff"
android:layout_below="#+id/textView9"
android:layout_alignStart="#+id/skickatrela2off" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Underhållsvärme"
android:textSize="29dp"
android:id="#+id/textView10"
android:layout_below="#+id/btnHeaton"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Termon"
android:id="#+id/btnTermon"
android:layout_below="#+id/textView10"
android:layout_toStartOf="#+id/btnHeatoff" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Termoff"
android:id="#+id/btnTermoff"
android:layout_alignBottom="#+id/btnTermon"
android:layout_toEndOf="#+id/btnTermon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Heaton"
android:id="#+id/txtHeaton"
android:layout_alignTop="#+id/statustxt"
android:layout_alignEnd="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Heatoff"
android:id="#+id/txtHeatoff"
android:layout_alignBottom="#+id/statustxt"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Termon"
android:id="#+id/txtTermon"
android:layout_alignBaseline="#+id/aoff"
android:layout_alignBottom="#+id/aoff"
android:layout_alignEnd="#+id/statustxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Termoff"
android:id="#+id/txtTermoff"
android:layout_alignTop="#+id/statustxt"
android:layout_alignEnd="#+id/txtHeatoff" />
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="c.timno.smsgsm20.SecondFragment"
android:id="#+id/fragmentsms"
android:layout_below="#+id/textView8"
android:layout_alignParentStart="true"
tools:layout="#layout/second_layout"
android:layout_above="#+id/textView10" />
</RelativeLayout>
</ScrollView>
I would suggest putting the ScrollView and the Fragment inside a new top-level element and then using the respective method within that element to adjust the size and position of each.
For instance, using a RelativeLayout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<ScrollView
android:id="#+id/scrollview"
android:layout_above="#+id/frag"
android:layout_width="match_parent"
android:layout_height="match_parent"
...>
<RelativeLayout
android:paddingBottom="50dp"
...>
...
</RelativeLayout>
...
</ScrollView>
<Fragment
android:id="#+id/frag"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="50dp"
...>
...
</Fragment>
</RelativeLayout>
(Note that the padding on the bottom of the RelativeLayout inside the ScrollView matches the height of the Fragment so that contents of the ScrollView don't get hidden behind the Fragment)
You could also do this using LinearLayout as the parent element with an attribute of android:orientation="vertical", and the ScrollView and Fragment each getting an appropriate layout_weight attribute, but that's not as clean imho, so I'll leave it to you if you'd prefer to do that.
<ScrollView>
<RelativeLayout>
//main content
</RelativeLayout>
<FrameLayout android:alignParentBottom="true"/> load fragment here dynamically(or not)
</ScrollView>
This worked for me. Check this question out aswell
i want to put five button in bottom but all button should be with same space means
below is image
Here you can see that second and third image is not in center below is my code i know that i have put padding but still my problem is not solving, i have tried using linearlayout also in that i have done by using weight=1 and width =0 but button is stretching
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/wall"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:drawingCacheQuality="high"
android:scaleType="fitXY" />
<Button
android:id="#+id/butRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="#drawable/check_right" />
<Button
android:id="#+id/butfav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/fvrt1" />
<Button
android:id="#+id/butLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:background="#drawable/check_left" />
<Button
android:id="#+id/butSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="39dp"
android:layout_toRightOf="#+id/butLeft"
android:background="#drawable/chek_wallpaper" />
<Button
android:id="#+id/butSetRingTone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginRight="36dp"
android:layout_toLeftOf="#+id/butRight"
android:background="#drawable/check_ringtone" />
can anybody help me?
I always use LinearLayout to achieve this and instead Buttons I'm using ImageView.
I have tried below code it's worked for me try this, just replace with your RelativeLayout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true" >
<ImageView
android:id="#+id/butLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/check_left" />
<View
android:id="#+id/butOne"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/check_right" />
<ImageView
android:id="#+id/butSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/chek_wallpaper" />
<View
android:id="#+id/butTwo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/check_right" />
<ImageView
android:id="#+id/butfav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fvrt1" />
<View
android:id="#+id/butThree"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/check_right" />
<ImageView
android:id="#+id/butSetRingTone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/check_ringtone" />
<View
android:id="#+id/butFour"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/check_right" />
<ImageView
android:id="#+id/butRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/check_right" />
</LinearLayout>
out put will be generated as you wish
Its a bit dirty solution but It'll work :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/aaaa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/butRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:minWidth="48dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/bbbb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/butfav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:minWidth="48dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/cccc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:minWidth="48dp"
android:orientation="vertical" >
<Button
android:id="#+id/butLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:minWidth="48dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/ddd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/butSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:minWidth="48dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/gggg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="#+id/butSetRingTone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:minWidth="48dp" />
</LinearLayout>
</LinearLayout>
Wrap the buttons in a LinearLayout and put spacings between each button (i also added one at the beginning and one after the last one, remove them if you don't want it).
assign a layout_weight for each spacing, don't set a weightSum on the LinearLayout.
Enjoy.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/wall"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawingCacheQuality="high"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/butRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/check_right" />
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/butfav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/fvrt1" />
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/butLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/check_left" />
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/butSetWallpaper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/chek_wallpaper" />
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/butSetRingTone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/check_ringtone" />
<!-- this is for the spacing -->
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</FrameLayout>
Why all of you doing trick with code. In android coding there is option available to give space between item.
<Space
android:id="#+id/space1"
android:layout_below="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="40dp"
/>
Just use this whenever you want. simple. hope this will help you.
The task is simple: there are two buttons and a TextView above them. All the widgets shoud be centered within the relative layout. The only one idea I have is create the third widget View and use it as a center axis for the buttons. Any ideas? A redundant layout isn't a good solution.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/app_name" />
<View
android:id="#+id/view_axis"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_below="#id/tv_progress"
android:layout_centerInParent="true" />
<Button
android:id="#+id/button_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tv_progress"
android:layout_toLeftOf="#id/view_axis"
android:text="#string/start" />
<Button
android:id="#+id/button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tv_progress"
android:layout_toRightOf="#id/view_axis"
android:text="#string/stop" />
</RelativeLayout>
If I understand what you want correctly, you can put the Buttons in a LinearLayout and center that
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/app_name" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#id/tv_progress">
<Button
android:id="#+id/button_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/start" />
<Button
android:id="#+id/button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stop" />
</LinearLayout>
I'm not sure if that's what you meant by a "redundant layout" but doing this is fine if it gives you what you want.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:id="#+id/sp_rooms"
android:layout_toLeftOf="#id/space"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Space
android:id="#+id/space"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btn_registration"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/space"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
This will vertically and horizontally center the whole block consisting of the textview + buttons
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerInParent="true">
<TextView
android:id="#+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/button_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/start" />
<Button
android:id="#+id/button_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stop" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I am trying to make my layout Scrollable by adding ScrollView as an parent for my Relative Layout.But my layout not scrolled.I have added the fillport property to true.
Here is my xml file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/repActivityTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ellipsize="middle"
android:textSize="18sp"
android:background="#android:color/darker_gray"
android:text="#string/representativeTitle" />
<TextView
android:id="#+id/repStreet"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/repImage"
android:layout_marginTop="14sp"
android:layout_toRightOf="#+id/repImage"
android:layout_margin="3sp"
android:text="#string/repStreet" />
<TextView
android:id="#+id/repState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/repStreet"
android:layout_toRightOf="#+id/repImage"
android:text="#string/repState" />
<TextView
android:id="#+id/repCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/repState"
android:layout_below="#+id/repState"
android:text="#string/repCountry" />
<com.google.android.maps.MapView
android:id="#+id/repMap"
android:layout_width="100dip"
android:layout_height="100dip"
android:paddingTop="2dp"
android:layout_marginTop="2dp"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/repImage"
android:apiKey="0lsQmtr2D241pSL53j0vQ2lYUs4_ZIWkIHyHAKw" >
</com.google.android.maps.MapView>
<View
android:id="#+id/firstHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/repMap"
android:layout_marginTop="54dp"
android:background="#android:color/black" />
<TextView
android:id="#+id/issues2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/issues1"
android:layout_centerVertical="true"
android:text="#string/issues2" />
<View
android:id="#+id/secondHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/accomplishments"
android:background="#android:color/black" />
<TextView
android:id="#+id/issues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignBottom="#+id/firstHorizontalLine"
android:layout_alignRight="#+id/repStreet"
android:text="#string/issues" />
<TextView
android:id="#+id/accomplish2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/accomplish1"
android:layout_below="#+id/accomplish1"
android:layout_marginTop="18dp"
android:text="#string/accomplishments2" />
<TextView
android:id="#+id/promises"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/issues"
android:gravity="center"
android:layout_below="#+id/accomplish2"
android:text="#string/promises" />
<View
android:id="#+id/thirdHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black"
android:layout_alignParentLeft="true"
android:layout_below="#+id/promises" />
<TextView
android:id="#+id/accomplishments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/issues2"
android:gravity="center"
android:layout_toLeftOf="#+id/repMap"
android:text="#string/accomplishments" />
<TextView
android:id="#+id/accomplish1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/secondHorizontalLine"
android:layout_marginTop="21dp"
android:text="#string/accomplishments1" />
<TextView
android:id="#+id/issues1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/issues2"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="#string/issues1" />
<ImageView
android:id="#+id/repImage"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/repActivityTitle"
android:contentDescription="#string/representativeImage"
android:paddingTop="2dp"
android:layout_marginTop="2dp"
android:scaleType="centerCrop"
android:src="#drawable/icon" />
<TextView
android:id="#+id/promise1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/thirdHorizontalLine"
android:layout_marginTop="19dp"
android:text="#string/promises1" />
<TextView
android:id="#+id/promise2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/promise1"
android:text="#string/promises2" />
</RelativeLayout>
</ScrollView>
Here I have used the ScrollView but the full content of layout is not as showing.As scrolls not work here.
Try to remove this line and check
android:fillViewport="true"
And also you can try height of relativelayout to match_parent instead of wrap_content
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
i want to have 2 Relative Layouts on my screen. One below another. I made this code but it doesn't work. In this case i can see only upper Relative Layout insted of both and this layout take whole space although i set wrap_content.
EDIT!: I put below the second code which fails too.
EDIT 2!: I found problem... That's a bit... sad. Problem lie in my theme. I set background to png file which was too big and when i applied default theme via manifest then this happend. When i removed it all is good.
This version fails too.
New code:
<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" >
<RelativeLayout
android:id="#+id/some_id"
android:layout_above="#+id/some_id2"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/main_button_localize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/main_localize" />
</RelativeLayout>
<RelativeLayout
android:id="#id/some_id2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<ToggleButton
android:id="#+id/main_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
Old code:
<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" >
<RelativeLayout
android:id="#+id/maps_manager_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<!-- Top -->
<Button
android:id="#+id/maps_manager_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_top_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_middle"
android:contentDescription="#string/empty" />
<!-- Middle -->
<Button
android:id="#+id/maps_manager_middle_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_top_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_middle_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_left"
android:layout_below="#id/maps_manager_top_middle"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_middle_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_middle"
android:layout_below="#id/maps_manager_top_right"
android:contentDescription="#string/empty" />
<!-- Bottom -->
<Button
android:id="#+id/maps_manager_bottom_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_middle_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_bottom_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_left"
android:layout_below="#id/maps_manager_middle_middle"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_middle"
android:layout_below="#id/maps_manager_middle_right"
android:contentDescription="#string/empty" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/maps_manager_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="true"
android:layout_below="#id/maps_manager_menu" >
<ToggleButton
android:id="#+id/maps_manager_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
Better you take LinearLayout with vertical orientation as Parent for two child RelativeLayouts. If you can put 80:20 height weights for the RelativeLayouts then it would fit to the entire screen.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<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" >
<RelativeLayout
android:id="#+id/maps_manager_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<!-- Top -->
<Button
android:id="#+id/maps_manager_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_top_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_middle"
android:contentDescription="#string/empty" />
<!-- Middle -->
<Button
android:id="#+id/maps_manager_middle_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_top_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_middle_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_left"
android:layout_below="#id/maps_manager_top_middle"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_middle_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_middle"
android:layout_below="#id/maps_manager_top_right"
android:contentDescription="#string/empty" />
<!-- Bottom -->
<Button
android:id="#+id/maps_manager_bottom_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_middle_left"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_bottom_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_left"
android:layout_below="#id/maps_manager_middle_middle"
android:contentDescription="#string/empty" />
<Button
android:id="#+id/maps_manager_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_middle"
android:layout_below="#id/maps_manager_middle_right"
android:contentDescription="#string/empty" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/maps_manager_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="true"
android:layout_below="#id/maps_manager_menu" >
<ToggleButton
android:id="#+id/maps_manager_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<ScrollView 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" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/maps_manager_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<!-- Top -->
<Button
android:id="#+id/maps_manager_top_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_top_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_left"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_top_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_top_middle"
android:contentDescription="#string/hello_world" />
<!-- Middle -->
<Button
android:id="#+id/maps_manager_middle_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_top_left"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_middle_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_left"
android:layout_below="#id/maps_manager_top_middle"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_middle_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_middle_middle"
android:layout_below="#id/maps_manager_top_right"
android:contentDescription="#string/hello_world" />
<!-- Bottom -->
<Button
android:id="#+id/maps_manager_bottom_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_middle_left"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_bottom_middle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_left"
android:layout_below="#id/maps_manager_middle_middle"
android:contentDescription="#string/hello_world" />
<Button
android:id="#+id/maps_manager_bottom_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/maps_manager_bottom_middle"
android:layout_below="#id/maps_manager_middle_right"
android:contentDescription="#string/hello_world" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/maps_manager_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/maps_manager_menu" >
<ToggleButton
android:id="#+id/maps_manager_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Follow the following steps:
Add ID to topmost relative layout say: android:id="#+id/rtvlt_first"
In second RelativeLayout remove alignparenttop property.
Add android:tobottomof="#id/rtvlt_first"...
Try this....
Good Luck!