splitting scrollview so it strectch for half the screen but it's ignoring the layout weight

scrollview android
vertical scrollview in android example
android scrollview not scrolling
horizontal scrollview in android example
how to add scrollview in android
how to add scrollbar in android-linearlayout
android:fillviewport
android scrollview scroll to position

I'm trying to create a vertical scroll view that shows up on the top half of the screen, the bottom half will have a few buttons.

I have a vertical linear layout with two vertical linear layouts inside of it (the top one containing the scrollview) and have set each of the two linear layouts to have a layout weight of 1 but the scroll view stretches past half the page regardless.

<LinearLayout
    android:id="@+id/mainlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:orientation="vertical">

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:background="@drawable/b_whitetrans4">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:fadeScrollbars="false"
            android:scrollbarThumbVertical="@android:color/holo_red_dark">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="5dp"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/settingtext"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="asdfasdfasdfasdfasdf"
                    android:textColor="@android:color/white"
                    android:textSize="20sp" />

            </LinearLayout>

        </ScrollView>
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:id="@+id/buttonlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">


    </LinearLayout>


</LinearLayout>

Oddly enough the scrollview doesn't stretch all the way to show all the content but it's definitely more than half the screen. This is what happens: https://www.screencast.com/t/VPHJwPhpLyb

While using weight in Linear Layouts, it is advisable to use height(if orientation is vertical) and width(if orientation is horizontal)=0dp. In your case, its vertical. Try doing that.

<LinearLayout
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">

<LinearLayout
    android:layout_weight="1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginBottom="10dp"
    android:background="@drawable/b_whitetrans4">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:fadeScrollbars="false"
        android:scrollbarThumbVertical="@android:color/holo_red_dark">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="5dp"
            android:orientation="vertical">

            <TextView
                android:id="@+id/settingtext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="asdfasdfasdfasdfasdf"
                android:textColor="@android:color/white"
                android:textSize="20sp" />

        </LinearLayout>

    </ScrollView>
</LinearLayout>

<LinearLayout
    android:layout_weight="1"
    android:id="@+id/buttonlayout"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="vertical">


</LinearLayout>

ScrollView, Doing so results in poor user interface performance and a poor user experience. android:fillViewport, Defines whether the scrollview should stretch its content  1 splitting scrollview so it strectch for half the screen but it's ignoring the layout weight Sep 8 '18 1 how to post an image from url with tkinter while in def function [duplicate] Apr 14 '15 0 How can I splice a tuple and assign to the same tuple?

Set the top LinearLayout's height to match_parent and remove the layout_weight attribute on the lower one.

Using UIScrollView with Auto Layout in iOS, How to set up a UIScrollView with AutoLayout with support for portrait different if you do not want the scroll view to occupy the entire screen. and the keyboard pops up, it blocks the bottom half of your screen; The ey will then stretch on auto rotation and no additional constraints in code are needed. 12 Minute Splits Stretch #Flexibility #Workout For #Beginners How To Tutorial. Ever wondered how to get your #splits but wasn't sure on what split stretches to try?! Then check out this splits

Maybe you can try setting the parent of the layouts as a RelativeLayout, then using alignParentTop/alignParentBottom instead of layout_weight on your LinearLayouts

https://developer.android.com/guide/topics/ui/layout/relative

Auto Layout Guide: Views with Intrinsic Content Size, Set the label's text and the text field's placeholder, and then set up the To have the text field stretch to fill the available space, its content Because both the label and text field are used to display text, the If there isn't enough space, the dummy views collapse to a 0-point width, and the button's divide the  A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.

Scrollview scroll to top programmatically swift, Nov 19, 2017 · I can grab the screen and scroll up, that works just fine, but I'd Nov 27, 2017 · 5: Drop on a scrollview and stretch it so it takes up the whole view. g. I have a checkbox half way down my form, and when the user checks it I want the scroll view horizontally. swift file is opened in the split editor along with the  Hi there, for this time let's split android app screen into two and compress two activity in a single window! All you need is just watch the entire tutorial and understand the procedure. Hope that

Layout Containers, Divide GridLayout width (300) by 3 to get 100. So first column is 1 x 100 = 100 pixels wide and second column is 2 x 100 = 200 pixels wide. 100 + 200 = 300. Take your cursor to the center (or so) of the topmost part of the open window on your screen. Depress the left mouse button and “grab” the window. Keep the mouse button depressed and drag the window all the way over to the RIGHT of your screen. It will automatically resize to take up the RIGHT half of your screen.

Get Started With React Native Layouts - Tuts+ Code, In this tutorial, you'll learn how to lay out React Native apps and how to For example, if we have layouts/StackLayout.js, do the following in App.js: the built-​in ScrollView component to automatically generate a vertical scrollbar just like flex-start , flex-end , and center , with the addition of a stretch value. To use the menu option to enter and exit full screen mode: Open your Edge browser. Select the Settings and More option, represented by three horizontal dots in the upper right-hand corner of the browser window. This opens a drop-down menu. Position your mouse over the Zoom option and then select the full screen icon.

Comments
  • exactly what I was looking for. works perfectly like this, thank you!
  • Glad this helped you out!