'how to make full screen activity with status bar on top of it while scrollbar is not scrolling full in Activity when it focus on editText?
Issue is that when I enter text in EditText then ScrollView does not work and does not scroll in my activity
fun statusBarColor(activity: Activity) {
val window = activity.window
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
//window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// finally change the color
//window.statusBarColor = ContextCompat.getColor(activity, R.color.colorPrimaryDark)
//window.setStatusBarColor(Color.TRANSPARENT);
}
//Manifest code on activity.
android:windowSoftInputMode="adjustResize">
Solution 1:[1]
You can use CoordinatorLayout as your root and NestedScrolView in it .
CoordinatorLayout as root reacts to keyboard and scrolls your layout to the top of your phone with assistant of NestedScrollView which your NestedScrollView includes your layout code .
To put the issue into perspective view
CoordinaterLayout > NestedScrolView > yourLayout
Change your layout XMl like code below
<android.support.design.widget.CoordinatorLayout
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">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- rest of your layout xml code-->
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
Solution 2:[2]
You can do this by having an activity and content layout file. From your example, we could have activity_login and content_login. In this example, I will assume that your activity is called LoginActivity.class
, so please update accordingly.
activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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"
android:orientation="vertical"
tools:context=".LoginActivity">
<include layout="@layout/content_user_profile" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
content_user_profile
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
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"
android:animateLayoutChanges="true"
android:background="@color/color_white"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".LoginActivity"
tools:showIn="@layout/activity_login">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--Have all your layout here as scrollviews expect one child. You can replace LinearLayout above with constraintLayout for more flexibility and responsiveness.-->
</Linearlayout>
</androidx.core.widget.NestedScrollView>
Manifest code for that particular activity
<activity
android:name=".LoginActivity"
android:colorMode="wideColorGamut"
android:exported="true"
android:label="@string/title_activity_login"
android:theme="@style/..."
android:windowSoftInputMode="adjustPan" />
Solution 3:[3]
getWindow().setBackgroundDrawableResource(R.drawable.iv_background);
set initViews()
to SignIn
activity and make it transparent to:
<item name="colorPrimaryVariant">#00000000</item>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alireza Bideli |
Solution 2 | |
Solution 3 | Jeremy Caney |