Layout not pushed up when Soft keyboard appears - android

I have a fragment of this given layout hierarchy,
Inside the view pager I have a Edit text. When keyboard appears to type in the text to EditText the entire layout is not pushed up. Instead the contents inside ViewPager is pushed up. I want the entire content inside the Outer Linear Layout to be pushed up when keyboard appears.
How can I achieve this?
Thanks.

Put your Parent LinearLayout inside a scrollview. This fixed my issue.

put your base layout inside the ScrollView
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/llPlayersName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
// do here the layout work
</LinearLayout>
</ScrollView>
remember scrollView cannon be used as the base layout, so you have to put the scrollView inside the LinearLayout or RelativeLayout.

In your activity's manifest entry, add
<activity ...
android:windowSoftInputMode="adjustPan">

Related

Issue in Android Layout - SoftKeyboard - Layout alignment

Hello Am working on some layout design in Android.
Layout contains an EditText inside Relativelayout and alignparentBottom='true' is given to Relativelayout.
When Soft-keyboard opens, My Views remains same - this is okay.
But, The Relativelayout which is inside bottom in screen : which contains EditText is not coming upper side of my SoftKeyboard.
So far, I have done as below to solve but getting an issue explained above: (with adjustPan, my bottom layout is coming upperside of softkeyboard but, it also scrolls the whole screen upper.)
In Manifeast :
android:windowSoftInputMode="adjustResize"
<activity
android:windowSoftInputMode="adjustResize"
android:name=".MyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="Camera Activity"
android:screenOrientation="portrait" />
What might be the solution?
thanks.
Try using ScrollView as parent view:
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
and remember that scrollview accepts only one direct child, so wrap your whole layout inside it.
also use linearLayout insted of relativeLayout, something like this:
<ScrollView>
<LinearLayout orientation="vertical">
<LinearLayout orientation="vertical">
<EditTexts />
</LinearLayout>
<Button />
</LinearLayout>

Android buttons at top and ScrollView at bottom of the screen

I have two buttons "Submit" and "Reset" on top of the ui and below this is my form. The problem is when i open my keyboard, the form scrolls up and goes below the top buttons layout. What should be the problem? I want to show buutons on top only.
try this
Replace to RelativeLayout to Linearlayout With orientation Vertical.
you can try to prevent the keyboard from scrolling up your form, so the keyboard will be above your layout by doing this :
add this to your manifest
<activity
android:name="yourActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustPan"/>
then put this inside your ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false">
</ScrollView>
if any trouble leave a comment !
Good luck

Scroll Through Multiple TexView in Nested LinearLayout

xml file for my About Screen .. i've done this because my app supports API 9 which does not support DialogFragments, so i am using another class to display another screen instead .. the problem is, i cant seem to scroll through the whole page, my .xml contains nested LinearLayout that also has TextViews .. i tried adding android:scrollbars="vertical" to the main <LinearLayout> but nothing happens .. i hope someone can help me out, thanks :)
My XML file Pasted here.
ScrollView can only support a single child. So enclose your nested LinearLayouts inside a single LinearLayout and further enclose that parent LinearLayout inside a ScrollView. I have done this for you. You can use this http://pastie.org/9528662
Wrap your root LinearLayout with ScrollView
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--your nested linearlayouts here-->
</LinearLayout>
</ScrollView>

listView inside of a linear layout with something else

i was just wondering if it was possible to have in one layout xml file, maybe a vertical linear layout at the top have a horizontal linearLayout and then below that (inside of the vertical layout) have a list view that takes up the rest of the screen?
I couldnt find any information specifically on this, and i'd like to know if its possible before i attempt it, thanks!
Give the ListView layout_height="0dp" and layout_weight="1". It will take up the remaining space not used buy the sibling LinearLayout.
<LinearLayout
android:layout_width:match_parent
android:layout_height:match_parent
android:orientation:vertical >
<LinearLayout
android:layout_width:match_parent
android:layout_height:wrap_content
android:orientation:norizontal >
<!-- other views --->
</LinearLayout>
<ListView
android:layout_width:match_parent
android:layout_height:0dp
android:layout_weight:1 />
</LinearLayout>

android: using adjustPan and without scrolling the title bar

I'm using android:windowSoftInputMode="adjustPan" in my manifest.xml.
It's doing me the job just fine but there is something retarded about it.
when i focus an EditText view that's, say in the bottom half of the screen, the title bar is also scrolled with the content of the activity.
image here
all i want is to freeze/float the title bar in place when scrolling the content. just like this:
image here
and no, I don't want to use adjustResize It overlaps views on top of each other
any help is greatly appreciated, been looking for the answer for a long time.
Found it!
Simply changing the root view in the layout xml file to a ScrollView does the job.
I don't even need to specify android:windowSoftInputMode
Of course I have to have everything else in a single layout as the child of the ScrollView
Edit
your .xml file should look like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
... >
<LinearLayout> // could be any other layout but linear works well here
//insert all other views of the activity here
</LinearLayout>
</ScrollView>
The answer suggested by Ace is essentially what is needed. My answer just aims to make things a little clearer.
There are two things you need to do. Firstly in the Manifest set the following on the activity. android:windowSoftInputMode="adjustResize"
Then, in the activity's layout you'll want to set a ScrollView beneath the Toolbar/Title Bar, as shown in the code below.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_height="?attr/actionBarSize"
.../>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
...>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
From what I understand, here's how it works.
When you open the soft keyboard on your device, it will 'adjustResize' the layout of the activity. As the layout sits in a ScrollView, this is the part which is resized, and made smaller. Therefore the Toolbar/Titlebar will stay in place and the layout in the ScrollView will be scrollable when the keyboard is shown.

Categories

Resources