0

I am developing a small android app that uses a ScrollView. I have a RelativeLayout in the ScrollView that I have already filled with items. Now I would like to scroll down to create more room to add more items, but Android Studio is not letting me do that, even though the scroll bar of the scroll view is visible. Is there a way to do that?

Here is the xml code, though I like working in the design view:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_new_reminder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context="com.steveops.locationreminder.NewReminderActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="700dp"
            android:padding="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="11dp"
            android:layout_marginStart="11dp">

            <TextView
                android:text="REMINDER NAME"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:text="Name"
                android:ems="10"
                android:id="@+id/editText2"
                android:layout_below="@+id/textView"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <TextView
                android:text="ACTIVATE ON"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView5"
                android:layout_below="@+id/editText2"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <CheckBox
                android:text="M"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView5"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:id="@+id/checkBox7" />

            <CheckBox
                android:text="T"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView5"
                android:layout_toRightOf="@+id/checkBox7"
                android:layout_toEndOf="@+id/checkBox7"
                android:id="@+id/checkBox8" />

            <CheckBox
                android:text="W"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox8"
                android:layout_toRightOf="@+id/checkBox8"
                android:layout_toEndOf="@+id/checkBox8"
                android:id="@+id/checkBox9" />

            <CheckBox
                android:text="T"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox9"
                android:layout_toRightOf="@+id/checkBox9"
                android:layout_toEndOf="@+id/checkBox9"
                android:id="@+id/checkBox10" />

            <CheckBox
                android:text="F"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox10"
                android:layout_toRightOf="@+id/checkBox10"
                android:layout_toEndOf="@+id/checkBox10"
                android:id="@+id/checkBox11" />

            <CheckBox
                android:text="S"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox11"
                android:layout_toRightOf="@+id/checkBox11"
                android:layout_toEndOf="@+id/checkBox11"
                android:id="@+id/checkBox12" />

            <CheckBox
                android:text="S"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox12"
                android:layout_toRightOf="@+id/checkBox12"
                android:layout_toEndOf="@+id/checkBox12"
                android:id="@+id/checkBox13" />

            <TextView
                android:text="BETWEEN"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView7"
                android:layout_below="@+id/checkBox7"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <TimePicker
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/timePicker"
                android:layout_below="@+id/textView7"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_toStartOf="@+id/checkBox12"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true" />

        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

As you can see in the screenshot, the scroll bar of the ScrollView is visible, but I am not able to scroll down to create enough space to add, for example, a new time picker. I hope I am making sense.

11
  • Could you post some code of your xml/ Commented Oct 26, 2016 at 4:27
  • Your code is working fine scroll is working and there is space as well at the bottom what do you want to acheive ? Commented Oct 26, 2016 at 4:41
  • Hi, @Steve your code is working ..just clean and rebuild your project. Commented Oct 26, 2016 at 4:44
  • Let me add a screen shot so you can see what I mean. Commented Oct 26, 2016 at 4:51
  • 1
    @Steve you have given fixed height to relative layout of 700 dp change it to wrap content Commented Oct 26, 2016 at 4:56

3 Answers 3

1

Use linearlayout with orientation vertical instead of relative layout inside scroll view.

Sign up to request clarification or add additional context in comments.

5 Comments

Still doesn't work. I added another time picker from the text-editor but its hidden and am not able to scroll it into view.
Change the outer relativelayout as well to linearlayout. Make sure that time picker is visible true by default.
Doesn't seem to work either. I'll just assume its not possible to scroll in design view and work with the text editor.
Don't worry, just put your code in github and give me link i will download and let you know. it will be some simple error.
No need, I think my editor was frozen somehow. I changed the device and it started working. Thanks a lot for trying to help.
1

Try this code

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="11dp"
            android:layout_marginStart="11dp"
            android:id="@+id/kk">

            <TextView
                android:text="REMINDER NAME"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView" />

            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="textPersonName"
                android:text="Name"
                android:ems="10"
                android:id="@+id/editText2"
                android:layout_below="@+id/textView"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <TextView
                android:text="ACTIVATE ON"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView5"
                android:layout_below="@+id/editText2"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <CheckBox
                android:text="M"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView5"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:id="@+id/checkBox7" />

            <CheckBox
                android:text="T"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textView5"
                android:layout_toRightOf="@+id/checkBox7"
                android:layout_toEndOf="@+id/checkBox7"
                android:id="@+id/checkBox8" />

            <CheckBox
                android:text="W"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox8"
                android:layout_toRightOf="@+id/checkBox8"
                android:layout_toEndOf="@+id/checkBox8"
                android:id="@+id/checkBox9" />

            <CheckBox
                android:text="T"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox9"
                android:layout_toRightOf="@+id/checkBox9"
                android:layout_toEndOf="@+id/checkBox9"
                android:id="@+id/checkBox10" />

            <CheckBox
                android:text="F"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox10"
                android:layout_toRightOf="@+id/checkBox10"
                android:layout_toEndOf="@+id/checkBox10"
                android:id="@+id/checkBox11" />

            <CheckBox
                android:text="S"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox11"
                android:layout_toRightOf="@+id/checkBox11"
                android:layout_toEndOf="@+id/checkBox11"
                android:id="@+id/checkBox12" />

            <CheckBox
                android:text="S"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/checkBox12"
                android:layout_toRightOf="@+id/checkBox12"
                android:layout_toEndOf="@+id/checkBox12"
                android:id="@+id/checkBox13" />

            <TextView
                android:text="BETWEEN"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView7"
                android:layout_below="@+id/checkBox7"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />

            <TimePicker
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/timePicker"
                android:layout_below="@+id/textView7"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_toStartOf="@+id/checkBox12"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true" />

        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

1 Comment

I have a solution already, I think my editor was somehow frozen. But its working now. Thanks for trying to help.
0

Found the solution, though I don't why it worked. I changed the selected device in the editor to a custom one and it just started working. I want to think that my editor was somehow frozen, that's why it wasn't scrolling.

I have never developed an app that exceeds the screen size thus the struggle.

Thank you all for trying to help, your responses are highly appreciated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.