i do not want to move my layout which has several views in it so when user touch edit text then keyboard open and my layout widget goes up. I have even use code in manifest
android:windowSoftInputMode="adjustPan"
then
android:windowSoftInputMode="adjustPan|adjustResize"
Nothing work so please help me
Here is my xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeAdd"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/my_toolbar">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/rv_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/footer_layout"
android:layout_marginTop="#dimen/dp_10"
android:background="#drawable/bg_add_buddy_fragment"
android:visibility="visible" />
</LinearLayout>
</ScrollView>
<include
android:id="#+id/footer_layout"
layout="#layout/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
You have a RecyclerView in a ScrollView. Remove the parent ScrollView.
Add android:windowSoftInputMode="adjustNothing" to AndroidManifest.xml for this activity.
Replace your ScrollView with **NestedScrollView** in your XML Layout and define
android:windowSoftInputMode="ajustPan|stateAlwaysHidden" in your manifest in particular activity
Add below code to your manifest
<activity android:name=".YourActivity"
android:windowSoftInputMode="adjustPan|stateHidden"/>
Related
all I am working on performing scrolling while the keyboard is open! My Screen is not scrolling upside while the keyboard appears. I want my screen need to scroll upside when the keyboard appears. As well as it showing me the bottom of the layout. Please suggest guidelines to fulfill that requirement. Is there any other way to do that thing?..... Thanks in advance.
I have tried many of them -
In the manifest file put that snippet :
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="adjustResize|stateHidden"
In XML file added the properties:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/appBarLayout"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbars="none">
But, this too didn't work. Please suggest any proper solution to it.
This is my XML file :
<?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=".work.CreateClassActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#color/ColorsWhite"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:weightSum="1"
app:popupTheme="#style/AppTheme.PopupOverlay">
<RelativeLayout
android:id="#+id/relativeLayoutLogo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.00"
android:visibility="visible">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="#string/create_class"
android:textColor="#color/colorTextDarkBlue"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/appBarLayout"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:weightSum="5">
</LinearLayout>
</ScrollView>
</RelativeLayout>
And this is my manifest file snippet:
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustResize|stateHidden"
android:theme="#style/AppTheme.NoActionBar" />
You just need to use adjustPan not adjustResize on the corresponding activity in AndroidManifest.xml. You just need to adjust it like this.
<activity
android:name=".work.CreateClassActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="adjustPan"
android:theme="#style/AppTheme.NoActionBar" />
Solution -
Step - 1 : In manifest file put that line in your particular activity:
android:windowSoftInputMode="adjustResize"
Step - 2 : In java file and in onCreate() put that line :
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Step - 3 : Before run the project - first clean project and uninstall previous apk.
Step - 4 : Run the project and you will get that desired result.
I have this code:
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeContainer"
xmlns:design="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:weightSum="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:theme="#style/Theme.AppCompat"
tools:context="com.tag.instagramdemo.example.MainActivity"
android:background="#drawable/background1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:itemIconTint="#color/text"
android:enabled="false"
app:itemTextColor="#color/text"
android:animateLayoutChanges="true"
android:clickable="false"
design:menu = "#menu/menu_main"
android:contextClickable="false"/>
When I use this layout. I can't see the bottom bar and I can only see the listview. At the top there is the list and nothing else.
I tried to resolve your issue.
I hope it will work for you :)
Please have a look and tried
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:design="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
android:layout_above="#+id/bottomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:theme="#style/Theme.AppCompat"
android:weightSum="1">
<ListView
android:id="#+id/lvRelationShip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:animateLayoutChanges="true"
android:background="#ffffff"
android:clickable="false"
android:contextClickable="false"
android:enabled="false"
design:menu="#menu/navigation" />
</RelativeLayout>
If you have not added a parent layout, do add a parent layout. Enclose the listview inside swiperefreshlayout and enclose the bottombar & swiperefreshlayout inside a parent layout (for eg., relative layout)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:design="http://schemas.android.com/apk/res-auto"
....>
<android.support.v4.widget.SwipeRefreshLayout
android:id="#+id/swipeContainer"
...>
<ListView
android:id=... >
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
android:enabled="false"
app:itemIconTint="#color/colorAccent"
app:itemTextColor="#color/colorPrimary"
android:animateLayoutChanges="true"
android:clickable="false"
android:contextClickable="false"
android:layout_below="#id/swipeContainer"
app:menu = "#menu/menu_main"/>
Also use
app:menu
instead of design:menu as suggested in
https://medium.com/#chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953
BottomNavigationView has a method inflateMenu(menu) and if you pass
your menu resource file inside it will work. Right after idea with the
wrong namespace appear in my mind so I tried to replace ‘design’ with
‘app’ namespace which automatically resolves the attributes. And it
actually works. The same story for other three attributes which exist
specifically for this view: itemBackground, itemIconTint,
itemTextColor.
I have the following xml
<RelativeLayout
...>
<Toolbar
.../>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/toolbar"
android:fitsSystemWindows="true"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TextInputLayout>
<TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
In my AndroidManifest.xml I set the windowSoftInputMode to adjustResize. But now when I click in one of those EditText fields the layout moves up and the actual field where I want to type is not even visible anymore. The scrolling works, but only downwards and not fully up. Any ideas on how to fix this? I don't want to use adjustPan because that disables the scroll in general.
I have a viewpager which contains a layout with scrollview as parent and webview as child.I had never faced a problem with portrait mode however in landscape mode it's acting very strange.
The screen is taking portrait height(which i'm assuming) in landscape too.
So the scrollview is getting activated when scrolling down.
If I block the touch by putting requestDisallowInterceptTouchEvent(true); but if I do that i'm unable to move to next page.
I gave the following in configChanges
android:configChanges="keyboardHidden|orientation|screenSize"
Here's my main xml code
<?xml version="1.0" encoding="utf-8"?><ScrollView
android:id="#+id/nestedScrollView"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/topMostLayout">
<RelativeLayout
android:id="#+id/topbarlayout"
android:layout_width="match_parent"
android:layout_height="43dp"
android:background="#android:color/white">
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#android:color/darker_gray"
android:layout_marginBottom="4dp" />
<com.mango.expert.utils.FullCard_ShadowLayout
android:id="#+id/activity_shadow_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:sl_cornerRadius="7dp"
app:sl_shadowColor="#color/shadow">
<FrameLayout
android:id="#+id/dummyLayoutForViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="#+id/dummyLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="2dp"
android:background="#drawable/for_full_card_bg" >
</LinearLayout>
</FrameLayout>
</com.mango.expert.utls.FullCard_ShadowLayout>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
Some tags are missing, i'm finding difficulty in pasting xml here.xml is totally fine.
Any help would be really great.Forgot to mention that webview is in Fragment and Scrollview is in main layout
You don't need to implement ScrollView for WebView. It's already have that feature it self.
Enable NestedScrolling on parent layout:
parent.setNestedScrollingEnabled(true);
or wrap your entire layout inside NestedScrollView:
<android.support.v4.widget.NestedScrollView
android:id="#+id/nScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<FrameLayout ...>
<ViewPager ... />
</FrameLayout >
</android.support.v4.widget.NestedScrollView>
I'm trying to achieve the following view in a chat app. There are basically two states one with the soft touch keyboard showing and one without.
So this is my initial state without the keyboard showing.
This is what happens when the keyboard shows up.
This is what i'm trying to achieve.
Note
I'm current using "adjust-resize" as the windowSoftInputMode. I know using "adjust-pan" will fix the issue, but with "adjust-pan" there are 2 problems :
The toolbar also moves up making space for the edit-text and keyboard.
The editText gets partly covered by the keyboard.
A layout experts help is needed here!
Thanks in advance.
Edit:
This is what my XML looks like:
<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">
<LinearLayout
android:id="#+id/view_group_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimaryDark"
android:elevation="4dip" >
<!-- Toolbar stuff -->
</android.support.v7.widget.Toolbar>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_bar"
android:layout_below="#+id/view_group_toolbar"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
<include
layout="#layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/view_group_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:gravity="center_vertical">
<include
layout="#layout/layout_that_covers_40%_of_the_screen"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="60dip"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:padding="8dip" >
<!-- This is where my edit text resides -->
</RelativeLayout>
</RelativeLayout>
So here is what I think you should do,
use
windowSoftInputMode="adjustResize" - The activity's main window is always resized to make room for the soft keyboard on screen. Also adjustResize keeps the ToolBar on top.
Try adding both your LinearLayouts inside a NestedScrollView. The reason I say this is because your NestedScrollView contents can scroll up.
I think your Layout will look like this- .
<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">
<LinearLayout
android:id="#+id/view_group_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimaryDark"
android:elevation="4dip" >
<!-- Toolbar stuff -->
</android.support.v7.widget.Toolbar>
</LinearLayout>
<NestedScrollView
android:layout_above="#+id/bottom_bar"
android:layout_below="#+id/view_group_toolbar">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
<include
layout="#layout/layout_that_covers_60%_of_the_screen (This is not my actual layout name :/ using it for understandability)"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/view_group_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:gravity="center_vertical">
<include
layout="#layout/layout_that_covers_40%_of_the_screen"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</NestedScrollView>
<RelativeLayout
android:id="#+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="60dip"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:padding="8dip" >
<!-- This is where my edit text resides -->
</RelativeLayout>
Let me know if this works for you.
EDIT 1:
If you have a RecyclerView inside your layouts, you may need to set this attribute for smooth scroll -
recyclerView.setNestedScrollingEnabled(false);