android questions about poping the soft keyboard - android

i want the whole layout move up to show while popping the soft keyboard, but the button on the bottom of the view cannot be seen.
the AndroidManifest.xml:
<activity
android:name="cn.duckr.android.plan.PlanConfirmPaymentActivity"
android:windowSoftInputMode="adjustPan"
style="#style/base_activity_style"
android:theme="#style/confirm_payment_anim_theme" />

To ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)—use "adjustResize".
link
android:windowSoftInputMode="adjustResize"

You can put whole layout except the particular button in a ScrollView to achieve this.
like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView5"
android:fillViewport="true">
//put your contents here..
</ScrollView>
<ImageButton
android:id="#+id/ibSample"
android:layout_width="50dp"
android:layout_height="50dp"
android:adjustViewBounds="true"/>
</RelativeLayout>

Related

Android:Bottom view should not appear above keyboard When soft keyboard open But Scroll should work. How to achieve?

I am using a Relative layout as root view and i have a view in bottom. When i am opening keyboard my View goes up and then i use
<activity
android:windowSoftInputMode="adjustPan">
</activity>
View that need to be in bottom
After doing this my View is not showing up but Still my content is not scrolling up, it's behind the screen. I want to scroll my content till the bottom
How to achieve it? Please help me.
Scroll the view after keyboard open
try this
android:windowSoftInputMode="adjustResize"
And if you are using full screen activity then nothing will work.
Try including your layout inside a ScrollView, it will allow you to scroll when keyboard is open.
Do like this...(Tested)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center">
//define you bottom view here
</RelativeLayout>
<ScrollView
android:id="#+id/scrollableContents"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="false"
android:layout_above="#id/footer">
//Rest of the view except bottom view
</ScrollView>
</RelativeLayout>
And in manifest define
android:windowSoftInputMode="stateVisible|adjustPan"
This code is working great for me.

Softkeyboard hides elements of my layout that I want to be visibles

I've got a layout that looks like first image and when I open the softkeyboard looks like the second image, but I want it how it seems on third image:
I read a lot about adjustpan and adjustresize on the manifest but nothing works, the xml structure is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/blanco"
android:gravity="top"
android:orientation="vertical"
android:weightSum="10" >
<!-- LOGO -->
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.7"
android:background="#color/green_logo"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="65dp" >
<ImageView
android:id="#+id/logo_registro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo_registro" />
</LinearLayout>
<FrameLayout
android:id="#+id/contentFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6.3" >
</FrameLayout>
</LinearLayout>
First part is the green part with the app logo and inside the FrameLayout I put Fragments that contains simple LinearLayouts or RelativeLayouts with parts of my Login forms.
Put this on your Manifest, inside the activity
<activity android:name=".YourActivity"
android:configChanges="keyboard|keyboardHidden"></activity>
Set your windowSoftInputMode in your manifest for this activity to be adjustResize. THere are 3 possible settings for this- nothing, resize (shrinks your app to fit the remaining space), and pan (scrolls your app so the focused field remains on screen).
Just Add the empty scrollview and it will work
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>

ScrollView does not work with ActionBar

ScrollView does not work, I have a layout with some components like EditText, and when I'm typing something EditText keyboard rises, and along the component, however it appears above the other, the ScrollView does not respond to their function.
Already googled, and found some similar problems, but none solved my problem.
Below my layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<TextView
android:id="#+id/txtDescricaoDocumento"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/edtDescricaoDocumento"
android:layout_alignBottom="#+id/edtDescricaoDocumento"
android:gravity="right"
android:text="Descrição:"
android:textAppearance="?android:attr/textAppearanceMedium" />
...
And my manifest.xml
<activity
android:name=".LancarDocumentoAcaoActivity"
android:windowSoftInputMode="adjustResize" >
</activity>
Couple things I've tried this without the relative layout inside of the scroll view...and scroll view worked perfectly.
1.Is relative layout necessary inside a linear layout? Try removing it if not.
2.Is the attribute WindowSoftInputMode necessary for the corresponding class if not you will have the soft keyboard covering view elements like it is mentioned.
Let me know if this works.

Resizable Scrolling layout with softKeyboard

I'm creating an Android application which requires a (1) static 40px tall Container (linear layout at the moment), (2) a scrollable-dynamically loaded content layout (ScrollView wrapped LinearLayout at the moment), (3) and an entry/answer field.
The Idea is (2) the scrollable-dynamically loaded content should be resized so that no matter what the (1) answer field and (3) container are visible. Also, I need every bit of content-within the dynamically loaded portion-able to be viewed.
The problem is that when the soft keyboard is shown I am getting a pan upward which hides the 40px container as well as a portion of my scrollable region (I can scroll all the way up and indeed the top few lines of my scrollable portion cannot be reached).
The activities entry in manifest:
<activity
android:name="com.xxxxx.xxxxx.xxxxxx.paid.activities.GamePlayActivity"
android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
android:label="#string/app_name" >
</activity>
The layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/game_play_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/activity_home_screen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40sp"
android:background="#FF000000"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/game_play_table"/>
</ScrollView>
<EditText
android:id="#+id/game_play_answer"
android:layout_width="match_parent"
android:layout_height="40sp"
android:layout_margin="3sp"
android:inputType="textAutoComplete"/>
</LinearLayout>
Any ideas would be greatly appreciated-I've been searching and trying different implementations found on stackoverflow however I have not met my requirement yet.

WindowSoftInputMode and ScrollView

My Android app's main activity looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background"
android:orientation="vertical" >
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical"
android:paddingLeft="60dp"
android:paddingTop="53dp" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/billAmountText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/billAmount_string"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/billAmount"
android:layout_width="173dp"
android:layout_height="wrap_content"
android:layout_below="#id/billAmountText"
android:layout_marginTop="3dp"
android:inputType="numberDecimal" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
In order to make sure the background image (defined in the first RelativeLayout) does not get squeezed when the keyboard pops up, I have set android:windowSoftInputMode="stateVisible|adjustPan in the manifest file for my activity. All good with the background and layout now, nothing gets resized.
But the problem is that my ScrollView doesn't work now because I suppose the system thinks the window doesn't need resizing due to my above modification to the manifest - so the ScrollView is not activated. The opposite happens when I take android:windowSoftInputMode="stateVisible|adjustPan out, the scrolling works, but the background gets squeezed when the keyboard pops out.
Is there any way to code it so that my background doesn't get squeezed, and my ScrollView still works? Thanks!
Try to use in your activity the property windowSoftInputMode with the following values:
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
I don't know if it's necessary but you can try to add to your layout's ScrollView tag the fillViewPort to true.
So it should look like something I show you below:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<!-- Other Views -->
</ScrollView>
Let me know about your progress.
In your scrollview put a relative layout, child 0 is an imageview, and child 1 is your content. Use the imageview for your background image (src) rather than the background of the scrollview. The imageview will respect scaleTypes, whereas the background of a layout will not.

Categories

Resources