Making a RelativeLayout fill the screen exactly - android

I have a RelativeLayout with several other children (other Layouts, imageviews and buttons).
All of the interior layouts/views adapt to the RelativeLayout in question. Can I make this RelativeLayout fill the screen exactly?
EDIT: My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/start_activity_relLayout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/start_activity_relLayout_container_bottom"
android:gravity="center_horizontal"
android:layout_gravity="center_vertical" >
<RelativeLayout
android:id="#+id/relLayout_dialogfragment_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linLayout_imageview_container"
android:gravity="center_vertical" >
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/tutorial_thirdview"
android:text="#string/button_servicerequirement" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/start_activity_relLayout_container_bottom"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="#dimen/two">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/image_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_cancel"
style="#style/button_standard_bright_smaller"
android:layout_marginRight="3dp"/>
<Button
android:id="#+id/image_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_ok"
android:layout_marginLeft="3dp"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
EDIT 2:
I am setting the imageview dynamically btw.

Have you tried setting RelativeLayout's layoutWidth and layoutHeight properties to match_parent in your xml layout file?

Related

Android ScrollView not srcoll inside LinearLayout

I have RelativeLayout inside SrcollView. That ScrollView will be an child of LinearLayout. In RelativeLayout I added views programmatically. But ScrollView is not scrolling.
startActivityCenterLayout - place between AutocompleteTextView's container and Button's container.
How I can resolve it?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/startActivityRootLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:background="#color/dark_cyan"
tools:context="com.geodevteam.geopay.project.activity.StartActivity">
<LinearLayout
android:orientation="vertical"
android:id="#+id/startActivityTopLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/dark_cyan">
<ImageView
android:id="#+id/startActivityLogoImageView"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#mipmap/ico"/>
<TextView
android:id="#+id/startActivityLogoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
style="#style/ApplicationNameTextView"
android:text="#string/application_title"/>
<AutoCompleteTextView
android:id="#+id/startActivityAutocompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
style="#style/AutocompleteTextViewTextColor"
android:hint="#string/start_to_input_name"/>
</LinearLayout>
<LinearLayout
android:id="#+id/startActivityCenterLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/startActivityTopLayout"
android:paddingBottom="10dp"
android:background="#color/dark_cyan">
<ScrollView
android:id="#+id/startActivityCenterLayoutScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="#+id/cardsRootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:id="#+id/startActivityBottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/dark_cyan">
<Button
android:id="#+id/startActivitySocialsButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_by_mail_button"
style="#style/LoginByMailButton"
android:text="#string/login_sign_using_social" />
<Button
android:id="#+id/startActivityEmailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_by_mail_button"
style="#style/LoginByMailButton"
android:text="#string/login_using_mail" />
</LinearLayout>
</RelativeLayout>
The layout is scrollable if necessary, so if you didn't put anything inside the Relative Layout, you aren't able to scroll.
This is Because hight of your ScrollView is 0dp. And Regarding that weight you have given to ScrollViewis work only if you have given weightSum to parent LinearLayout.
Eighter you give weightSum to LinrearLayout or Change Hight of ScrollView to match_parent.
Happy Coding.
Now scrollview is working. Code down below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/startActivityRootLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
android:background="#color/dark_cyan"
tools:context="com.geodevteam.geopay.project.activity.StartActivity">
<LinearLayout
android:orientation="vertical"
android:id="#+id/startActivityTopLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/dark_cyan">
<ImageView
android:id="#+id/startActivityLogoImageView"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:src="#mipmap/ico"/>
<TextView
android:id="#+id/startActivityLogoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
style="#style/ApplicationNameTextView"
android:text="#string/application_title"/>
<AutoCompleteTextView
android:id="#+id/startActivityAutocompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
style="#style/AutocompleteTextViewTextColor"
android:hint="#string/start_to_input_name"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:id="#+id/startActivityBottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_alignParentBottom="true"
android:background="#color/dark_cyan">
<Button
android:id="#+id/startActivitySocialsButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_by_mail_button"
style="#style/LoginByMailButton"
android:text="#string/login_sign_using_social" />
<Button
android:id="#+id/startActivityEmailButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/login_by_mail_button"
style="#style/LoginByMailButton"
android:text="#string/login_using_mail" />
</LinearLayout>
<LinearLayout
android:id="#+id/startActivityCenterLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/startActivityBottomLayout"
android:layout_below="#id/startActivityTopLayout"
android:background="#color/dark_cyan">
<ScrollView
android:id="#+id/startActivityCenterLayoutScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:id="#+id/cardsRootLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>

Scrollable XML View

I can't get a view area to scroll. I have tried many variations of tags but without success. I need the light yellow (#FFFF99) area to be very large and that the user can move it around within the view area but the buttons remain visible. Here is my XML code.
<?xml version="1.0" encoding="utf-8"?><!--<?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="vertical">-->
<LinearLayout 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"
android:background="#FFCCCCCC"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageButton
android:id="#+id/play_btn"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="#string/dice6"
android:src="#drawable/play" />
<ImageButton
android:id="#+id/exit_btn"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="#string/exit"
android:src="#drawable/exit" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Commentary"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
adroid:scrollbarAlwaysDrawVerticalTrack="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<view
android:id="#+id/drawing"
class="com.summit.DrawView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.01"
android:background="#FFFF99"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Its because inside your scrollview the width of linear layout is wrap content. And the views width is match parent. These two contradict each other.

How to divide screen space between ImageView and TextView in RelativeLayout

I need to put ImageView and below it should be textview. I have done this by using text and image in RelativeLayout. Everything is ok , but I need to give more space (2/3) to ImageView . How can I do this ?
Thx in advance .
<RelativeLayout
android:id="#+id/rel_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_above="#+id/adPlaceholder" >
<ImageView
android:id="#+id/image_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/text_main"
android:layout_below="#+id/image_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/hello_world"/>
</RelativeLayout>
I think LinearLayout is more appropriate for your situation
You can use LinearLayout with android:orientation="vertical" and android:weightSum="3"
Then you can give android:layout_weight="2" to the ImageView and android:layout_weight="1" to the TextView
The final XML code after update
<LinearLayout
android:id="#+id/rel_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_above="#+id/adPlaceholder"
android:orientation="vertical"
android:weightSum="3" >
<ImageView
android:id="#+id/image_first"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="2"
android:src="#drawable/ic_launcher"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/text_main"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:layout_centerHorizontal="true"
android:text="#string/hello_world"/>
</LinearLayout>
Are you wanting something, or is that your image occupy more space to your text, you can do this type:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rel_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/adPlaceholder"
android:layout_alignParentLeft="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dip"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/image_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/text_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="#string/hello_world" />
</LinearLayout>
</RelativeLayout>
I think the best solution would be to put a LinearLayout inside ReletiveLayout and set weightsum to the inner LinearLayout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rel_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/adPlaceholder"
android:layout_alignParentLeft="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="3" >
<ImageView
android:id="#+id/image_first"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/text_main"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="#string/hello_world" />
</LinearLayout>
</RelativeLayout>
Also note that the layout_weight of ImageView is 1 out of 3 making in 2/3 of the parent and that of TextView is 2 out of 3 making it cover 1/3 of parent.

How to center a view using RelativeLayout?

I wanted to know how to center a View between two other views (or between a view and the parent edge) using RelativeLayout.
For example, if I have the following...
How do I vertically center the Button between the ImageView and the bottom of the screen using RelativeLayout?
I'm looking for a solution where...
the Button is not stretched in any way
there are no nested layouts
And I'm trying to do this in the XML layout (not programmatically).
You can use following:
<RelativeLayout
android:layout_below="#id/theImageView"
android:align_parentBottom="true"
android:layout_width="match_parent"
android:layout_height="200dp" >
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="onClickButton"
android:textSize="20sp"
android:text="Go"/>
</RelativeLayout>
There's unfortunately no easy way to do this. You can either nest layouts, or do it at runtime. The simplest way is to nest layouts:
<LinearLayout
android:width="match_parent"
android:height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/my_top_image"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/my_button_label"/>
</RelativeLayout>
</LinearLayout>
This puts the image at the top. Below that, the layout_height=0 and layout_weight=1 attributes on the RelativeLayout cause it to take up all the remaining space. You can then center the button in the RelativeLayout. You can play with padding on the button to get it to the size you want.
Use below XMl code for that, it will solve your problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/mLlayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/mImgView1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/ic_launcher" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="2" >
<Button
android:id="#+id/Btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Dipak" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
use this android:layout_centerInParent="true" in XML file..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.8"
android:background="#00ff00" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.2" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Button" />
</RelativeLayout>
</LinearLayout>
#Gus you can create center view between two other view... this is not exact you must try with
this way....
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#00ccFF"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:layout_width="59dp"
android:layout_height="59dp"
android:layout_alignRight="#+id/linearLayout1"
android:layout_alignTop="#+id/linearLayout1"
android:layout_marginRight="-21dp"
android:layout_marginTop="-21dp"
android:background="#FFccFF"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
I think what you just need is to allign the imageview as you would normally done and align the button using layout_below , no need for hardcoding nor using nested views use android:gravity="center" on the button you're done
<RelativeLayout
android:layout_below="#id/theImageView"
android:align_parentBottom="true"
android:layout_width="match_parent"
android:layout_height="200dp" >
<ImageView
android:id="#+id/imgview"
android:layout_width="match_parentmat"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imgview"
android:gravity="center"
android:onClick="onClickButton"
android:textSize="20sp"
android:text="Go"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/wood" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView1"
android:layout_below="#+id/imageView1"
android:layout_marginLeft="101dp"
android:layout_marginTop="53dp"
android:text="Image Button" />
</RelativeLayout>

linearlayout is not displaying properly

I have created this main XML file in my project. I have parsed XML file and displayed dynamically in linear layout1. But linearlayout2 is not displaying in my result. please help me. This is my main XML file . I am using one XML file to display my widgets
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearlayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:gravity="bottom"
android:text="Signature" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/button2"
android:layout_weight="1"
android:gravity="bottom"
android:text="Submit" />
</LinearLayout>
</LinearLayout>
copy and paste this layout, its modified by adding layout_weight in your scroll view and linearlayout2 to equally distribute the screen. Hope it fulfills your requirements.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearlayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal"
android:layout_weight="1" >
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:gravity="bottom"
android:text="Signature" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="30dp"
android:layout_toRightOf="#+id/button2"
android:layout_weight="1"
android:gravity="bottom"
android:text="Submit" />
</LinearLayout>
</LinearLayout>
Better you use relative layout for your problem.
I think its easy to solve:
Your ScrollView defines the layout height to "wrap-content", it means
"childs can take all needed space". but, in the first child you define the height
as "match_parent". it means "i need most of space as i can get".
To solve the problem, simply let the height of the linearlayout within the ScrollView
"0dip" and set the layout_weight to "1".

Categories

Resources