Search code examples
androidandroid-layoutandroid-xml

ScrollView not scrolling as parent and RelativeLayout as child


I know this question has been asked several times before, but none of the answers worked for me so I am reposting it again. I am using a scrollview as a parent layout and a relative layout as child. Here is my code :

<?xml version="1.0" encoding="utf-8"?>

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/sv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:background="@drawable/grdnt">
    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"    >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:paddingLeft="60dp"
            android:paddingRight="60dp">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="16dp">
                    <ImageView
                        android:layout_width="20dp"
                        android:layout_height="20dp"
                        android:src="@drawable/ic_ip"
                        android:layout_gravity="center"/>
                    <EditText
                        android:id="@+id/ip"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Server Adress"
                        android:textColorHint="#d9e5f3"
                        android:layout_marginLeft="15dp"
                        android:background="#00000000"
                        android:letterSpacing="0.1"
                        android:textSize="16dp"
                        android:inputType="text"
                        android:textColor="#fff"
                        android:fontFamily="@font/lato"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#4a5a71"></LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="16dp">
    
                    <ImageView
                        android:layout_width="18dp"
                        android:layout_height="20dp"
                        android:layout_gravity="center"
                        android:src="@drawable/ic_g" />
                    <EditText
                        android:id="@+id/port"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="Port"
                        android:textColorHint="#d9e5f3"
                        android:layout_marginLeft="15dp"
                        android:background="#00000000"
                        android:inputType="text"
                        android:letterSpacing="0.1"
                        android:textSize="16dp"
                        android:textColor="#fff"
                        />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:background="#4a5a71"></LinearLayout>
    
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingLeft="60dp"
            android:paddingRight="60dp"
            android:orientation="vertical"
            android:gravity="bottom"
            android:layout_marginBottom="20dp">
            <TextView
                android:id="@+id/sub"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#009a9a"
                android:text="Submit"
                android:textColor="#d9e5f3"
                android:textStyle="bold"
                android:gravity="center"
                android:layout_gravity="bottom"
                android:padding="16dp"
                android:layout_marginBottom="50dp"
                android:letterSpacing="0.2"/>
    
    
        </LinearLayout>
        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:layout_marginBottom="400dp">
        <ImageView
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:src="@drawable/ic_settings"
            />
    </LinearLayout>
</RelativeLayout>
</ScrollView>

I tried to put it inside LinearLayout but still nothing, I also tried to change the RelativeLayout to LinearLayout and nothing.

Any suggestions?


Solution

  • Ok, i figured out what was the problem and I hope this might help someone one day. The problem was my style.xml file i was using the item "windowFullscreen" wich it was preventing the app from scrolling.

    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Customize your theme here. -->
        ...
        <item name="android:windowFullscreen">true</item>
    </style>
    

    So all i've had to do was deleting that full screen attribute.