PlayHardGoPro
PlayHardGoPro

Reputation: 2933

ScrollView not scrolling with full Size app

So I have some difficult trying to make my app show fullscreen (without that damn actionBar).

I achieved it by doing this on my mainActivity.java:

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);  

If I comment the line above, the scroll works again, but then the background image start to move everytime I open/close the keyboard.

The problem now is that the ScrollView is no longer scrolling the elements when I open the keyboard and it hides the button.

CODE:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ghaleon.hqsm.MainActivity">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/bg2"
        android:scaleType="centerCrop"
    />

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="18dp"
        app:srcCompat="@drawable/logo"
        android:layout_marginBottom="30dp"
        />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imgLogo"
        android:fillViewport="true"
    >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/transp_white_rect"
            android:layout_marginStart="30dp"
            android:layout_marginEnd="30dp"
            android:layout_marginTop="50dp"
            >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Faça seu Cadastro"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold"
                android:layout_marginBottom="5dp"
                android:paddingStart="15dp"
                android:paddingEnd="10dp"
                android:paddingTop="10dp"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="E mostre ao mundo o seu talento"
                android:textColor="@color/white"
                android:textSize="15sp"
                android:layout_marginBottom="30dp"
                android:paddingStart="15dp"
                android:paddingEnd="10dp"
                android:paddingTop="10dp"
                />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="@string/email"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_person_pin"
                android:id="@+id/userEmail"
                android:layout_marginBottom="10dp"

                />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="@string/password"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_lock_outline"
                android:inputType="textPassword"
                android:layout_marginBottom="10dp"
                android:id="@+id/userPassword"
            />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="Confirm Password"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_lock_outline"
                android:inputType="textPassword"
                android:id="@+id/userConfirmPassword"
                android:layout_marginBottom="15dp"
            />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:text="REGISTER"
                android:textColor="@color/white"
                android:textStyle="normal"
                android:background="@drawable/register_button"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="15dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                />

        </LinearLayout>

    </ScrollView>

</RelativeLayout>

How to keep the app NOT SHOWING the actionBar but also allow the scrollView to scroll?

ScreenShot: As you guy can see, I have a button below those AutoCompleteTextView. I can't scroll down to click the button. enter image description here

MANIFEST

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.biruleibe.hqsm">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity" android:windowSoftInputMode="stateVisible|adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>  
Example without fullscreen: (The purple little bar shows up with clock/battery/etc... AND the background image MOVES whenever I open/close the keyboard). But the scroll works.

enter image description here

Upvotes: 2

Views: 856

Answers (1)

Aman Verma
Aman Verma

Reputation: 3325

First thing you should set your style as -

<style name="themex" parent="Theme.AppCompat.Light.NoActionBar">

// your style
<item name="android:windowFullscreen">true</item>

</style>

And in Android Manifest you should define windowsoftinputmode as

<activity android:name=".MainActivity"
            android:windowSoftInputMode="adjustNothing"
            />

And finally the Layout. Its a hack and i have done it so many time without any issues.

Add an empty textview below you Button And set MarginTop to around - 300dp

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ghaleon.hqsm.MainActivity">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/bg2"
        android:scaleType="centerCrop"
    />

    <ImageView
        android:id="@+id/imgLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="18dp"
        app:srcCompat="@drawable/logo"
        android:layout_marginBottom="30dp"
        />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imgLogo"
        android:fillViewport="true"
    >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@drawable/transp_white_rect"
            android:layout_marginStart="30dp"
            android:layout_marginEnd="30dp"
            android:layout_marginTop="50dp"
            >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Faça seu Cadastro"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold"
                android:layout_marginBottom="5dp"
                android:paddingStart="15dp"
                android:paddingEnd="10dp"
                android:paddingTop="10dp"
                />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="E mostre ao mundo o seu talento"
                android:textColor="@color/white"
                android:textSize="15sp"
                android:layout_marginBottom="30dp"
                android:paddingStart="15dp"
                android:paddingEnd="10dp"
                android:paddingTop="10dp"
                />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="@string/email"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_person_pin"
                android:id="@+id/userEmail"
                android:layout_marginBottom="10dp"

                />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="@string/password"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_lock_outline"
                android:inputType="textPassword"
                android:layout_marginBottom="10dp"
                android:id="@+id/userPassword"
            />

            <AutoCompleteTextView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:hint="Confirm Password"
                android:background="@drawable/rounded_white"
                android:layout_marginStart="15dp"
                android:layout_marginEnd="15dp"
                android:drawableLeft="@drawable/ic_lock_outline"
                android:inputType="textPassword"
                android:id="@+id/userConfirmPassword"
                android:layout_marginBottom="15dp"
            />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:text="REGISTER"
                android:textColor="@color/white"
                android:textStyle="normal"
                android:background="@drawable/register_button"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="15dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                />
<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=""

                android:layout_marginTop="300dp"
                />


        </LinearLayout>

    </ScrollView>

</RelativeLayout>

Upvotes: 3

Related Questions