Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ScrollView and buttons at bottom of the screen

I want to implement this: A ScrollView that contains many elements (ImageViews, TextViews, EditTexts etc) and then after the ScrollView some buttons (which are custom ImageViews) that appear always exactly at the bottom of the screen.

If I use the android:fillViewport="true" attribute, then if the elements of the ScrollView are too big to fit in the screen size the buttons get invisible . If I use the android:Weight=1 attribute then the ScrollView gets only 50% of the Screen when the screen is big and it can fit (I want the buttons to take a small percentage, about 10%). If I set the android:Weight to bigger values then the buttons appear very small.

Please help! Maybe it is something simple that I overlooked but I’ve been banging my head for hours!

like image 889
george Avatar asked Feb 17 '12 10:02

george


People also ask

How do I scroll to the bottom of my Android screen?

Here's how you can use it: Open a webpage in a browser on your Android device. Make sure the webpage is long enough so that the browser shows a scroll bar. Once there, to get to the bottom of the page, simply tap the top right corner on your device.

What is the difference between ScrollView and NestedScrollView in Android?

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. It is enabled by default. NestedScrollView is used when there is a need for a scrolling view inside another scrolling view.

What is the difference between ScrollView and horizontal ScrollView?

ScrollView and HorizontalScrollView has same attributes, the only difference is scrollView scroll the child items in vertical direction while horizontal scroll view scroll the child items in horizontal direction.


1 Answers

Just created and tested it. Looks like you want.

<?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"                 android:layout_width="match_parent"                 android:layout_height="match_parent">      <LinearLayout             android:id="@+id/buttons"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal"             android:gravity="center"             android:layout_alignParentBottom="true">         <Button                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="Custom Button1"/>         <Button                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:text="Custom Button2"/>     </LinearLayout>      <ScrollView             android:layout_width="match_parent"             android:layout_height="match_parent"             android:layout_above="@id/buttons">          <!--Scrollable content here-->         <LinearLayout                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:orientation="vertical">                             <TextView                     android:layout_height="wrap_content"                     android:layout_width="wrap_content"                     android:text="test text"                     android:textSize="40dp"/>         </LinearLayout>     </ScrollView>  </RelativeLayout> 
like image 148
Oleksii Masnyi Avatar answered Sep 28 '22 05:09

Oleksii Masnyi