Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:49:37+00:00 2026-05-26T11:49:37+00:00

I have a linearLayout which is surrounded by a scrollView in order to make

  • 0

I have a linearLayout which is surrounded by a scrollView in order to make it for smaller screens scrollable. In the linear layout I have 3 childs which are also linearlayout.

This is working fine. But I also want to support larger screens. At the moment I get with a larger screen space left on the bottom of the screen. I want to have the buttons (navigation bar) be always at the bottom. for larger screens (height) I would like to add at the top of the screen an empty view which fills out the space that is more provided by the larger screen.

How can I achieve that? i tried a lot with weight attribute but didnt get it working.

Here the layout:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#8db9f6"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#8db9f6">
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_marginTop="8dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="test"
                android:id="@+id/test"
                android:paddingLeft="10dp"
                android:textStyle="bold"
                android:textSize="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TextView>
            <View
                android:layout_width="wrap_content"
                android:layout_height="0dip"
                android:layout_weight="1"/>
            <ImageButton
                android:id="@+id/btnName"
                android:scaleType="center"
                android:layout_width="60dp"
                android:layout_height="48dp"
                android:src="@android:drawable/ic_menu_edit">
            </ImageButton>
        </LinearLayout>
        <EditText
            android:id="@+id/edittest"
            android:editable="false"
            android:hint="@string/test"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </EditText>
        <TextView
            android:text="@string/optionalText"
            android:id="@+id/test1"
            android:paddingLeft="10dp"
            android:textSize="12dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </TextView>
        <TextView
            android:id="@+id/space"
            android:layout_width="fill_parent"
            android:layout_marginTop="4dp"
            android:layout_height="3sp"
            android:background="#333142">
        </TextView>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_marginTop="5dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="TEST TESt"
                android:id="@+id/test2"
                android:paddingLeft="10dp"
                android:layout_marginTop="5dp"
                android:textStyle="bold"
                android:textSize="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TextView>
            <View
                android:layout_width="wrap_content"
                android:layout_height="0dip"
                android:layout_weight="1"/>
            <ProgressBar
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:id="@+id/progressbar"/>
            <ImageButton
                android:id="@+id/btnPicture"
                android:scaleType="center"
                android:layout_width="60dp"
                android:layout_height="48dp"
                android:src="@android:drawable/ic_menu_edit">
            </ImageButton>
        </LinearLayout>
        <FrameLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:background="#ffffff"
            android:layout_gravity="center"
            android:layout_width="fill_parent"
            android:layout_height="150dip">
            <ImageView
                android:id="@+id/test3"
                android:layout_width="400dip"
                android:layout_height="150dip"
                android:layout_gravity="center"
                android:scaleType="fitCenter"
                android:src="@drawable/test1"/>
            <TextView
                android:id="@+id/text"
                android:layout_gravity="bottom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="8dp"
                android:text="test test"/>
        </FrameLayout>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            android:layout_marginTop="3dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button
                android:id="@+id/scaleMinus"
                android:textSize="14dp"
                android:layout_weight="1"
                android:layout_gravity="bottom"
                android:layout_width="fill_parent"
                android:layout_height="40dp"
                android:text="@string/zoomOut"/>
            <Button
                android:id="@+id/scalePlus"
                android:textSize="14dp"
                android:layout_weight="1"
                android:layout_gravity="bottom"
                android:layout_width="fill_parent"
                android:layout_height="40dp"
                android:text="@string/zoomIn"/>
        </LinearLayout>
        <TextView
            android:id="@+id/balken"
            android:layout_width="fill_parent"
            android:layout_marginTop="4dp"
            android:layout_height="3sp"
            android:background="#333142">
        </TextView>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_marginTop="5dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="test test"
                android:id="@+id/test3"
                android:paddingLeft="10dp"
                android:textStyle="bold"
                android:textSize="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TextView>
            <View
                android:layout_width="wrap_content"
                android:layout_height="0dip"
                android:layout_weight="1"/>
            <EditText
                android:id="@+id/test4"
                android:editable="false"
                android:layout_width="100dp"
                android:layout_height="wrap_content">
            </EditText>
            <TextView
                android:text="test"
                android:id="@+id/mtest4"
                android:paddingLeft="10dp"
                android:textStyle="bold"
                android:textSize="20dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </TextView>
            <View
                android:layout_width="wrap_content"
                android:layout_height="0dip"
                android:layout_weight="1"/>
            <ImageButton
                android:id="@+id/test5"
                android:scaleType="center"
                android:layout_width="60dp"
                android:layout_height="48dp"
                android:src="@android:drawable/ic_menu_edit">
            </ImageButton>
        </LinearLayout>
        <TextView
            android:id="@+id/balken"
            android:layout_width="fill_parent"
            android:layout_marginTop="4dp"
            android:layout_height="3sp"
            android:background="#333142">
        </TextView>
        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            android:background="#000000"
            android:paddingTop="5dp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button
                android:id="@+id/save"
                android:textSize="18dp"
                android:layout_weight="1"
                android:layout_gravity="bottom"
                android:layout_width="fill_parent"
                android:layout_height="60dp"
                android:text="@string/save"/>
            <Button
                android:id="@+id/cancel"
                android:textSize="18dp"
                android:layout_weight="1"
                android:layout_gravity="bottom"
                android:layout_width="fill_parent"
                android:layout_height="60dp"
                android:text="@string/abort"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:49:37+00:00Added an answer on May 26, 2026 at 11:49 am

    Wrap the entire layout in a Relative Layout. Use a relative layout as your root element and set the Linear Layout containing your buttons to layout_alignParentBottom=”true” and the ScrollView set to layout_alignParentTop=”true”.

    The LinearLayout containing the buttons and the ScrollView should be direct children of the RelativeLayout.

    <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
             <LinearLayout <-- containing the layout minus the buttons
                   android:id="@+id/SV"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_alignParentTop="true">
                <The Rest Of The Layout>
             </LinearLayout>
             <LinearLayout
                   android:id="@+id/LLButtons"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:layout_alignParentBottom="true">
              <Buttons>
              </LinearLayout>
    </ScrollView>
    

    If you want the buttons to be always at the bottom of the screen alignParentBottom. If you want the buttons to always be at the bottom of the scrollview alignBelow=”@id/SV”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linear layout with this form <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical
I have a layout which contains some views like this: <LinearLayout> <TextView...> <TextView...> <ImageView
I have android app in which one layout contains Linearlayout , ScrollView , TextView
I have a linear layout that contains 6 images, which span the linear layout
I have the following Layout which does not work: <LinearLayout android:orientation=horizontal android:layout_width=match_parent android:id=@+id/experienceLayout android:background=#ffffff
I have a listview which displays emails with the following layout: email@address.com category //This
I have a LinearLayout, which only contains one button. I want this button to
I have an AbsoluteLayout which has an OnTouchListener . Inside this layout there is
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have a LinearLayout which has a background image (a 9 patched png file).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.