I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_above="#+id/edittext">
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line1"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line2"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="line3"/>
</LinearLayout>
<EditText
android:id="#id/edittext"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="5dp"
android:text="test"
android:layout_alignParentBottom="true"
android:imeOptions="flagNoExtractUi"
/>
</RelativeLayout>
and in landscape on a Nexus one it looks like:
Is there a way to fix this, but keep flag flagNoExtractUi ?
Define <activity> inside Android manifest like:
<activity android:name=".TodoEdit"
android:windowSoftInputMode="adjustResize">
You can add a ScrollView so that when appears the keyboard, it scrolls automatically to make the view fully visible.
It seems to be a bug in Android but I found a solution! Just replace android:imeOptions="flagNoExtractUi" with android:imeOptions="flagNoFullscreen" and everything will work now.
Related
I have one activity and in this activity's windowSoftInputMode is stateAlwaysHidden
android:windowSoftInputMode="stateAlwaysHidden"
i created custom Xml file and in this xml i have one edittext in top position and one button in bottom position
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:minHeight="#dimen/u_base_min_height">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:minHeight="#dimen/u_base_min_height"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/transfer_headerView_height">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="#dimen/u_common_margin_left"
android:paddingRight="#dimen/u_common_margin_right">
<Button
android:id="#+id/u_done"
android:layout_width="fill_parent"
android:layout_height="#dimen/u_widget_height"
android:background="#drawable/rounded_corners_blue"
android:text="#string/u_register_next"
android:textColor="#ffffff"
android:textSize="#dimen/u_common_text_size" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/u_common_margin_left" />
</LinearLayout>
</RelativeLayout>
when keyboard is showing i can not show my button whitch is a bottom position,scrollview now working.
i searched about my problem and i tryed to change windowSoftInputMode in manifest file
android:windowSoftInputMode="adjustResize"
but i don't need this solution because my button moving keyboard up when my keyboard is showing...
how i can solve my problem? if anyone knows solution please help me
thanks everyone
put your bottom button outside the scrollview. Make two separate layouts. In upper layout put your scrollview content and in lower layout put your bottom button.
For that use below code
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="true">
I have a "has_groups_fragment" fragment, and it has an EditText element.
When I try to click on it, the keyboard is not responding.
the layout is the following:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/has_groups"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ft_background"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/searchGroupsArea"
android:layout_width="350dp"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/inputGroupSearch"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="0.86"
android:clickable="true"
android:ems="10"
android:hint="Search a group..."
android:inputType="textVisiblePassword"
android:textIsSelectable="true" >
<requestFocus />
</EditText>
<ImageView
android:id="#+id/magnifyingGlass"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:src="#drawable/search_icon" />
</LinearLayout>
<ListView
android:id="#+id/groupsList"
android:layout_width="fill_parent"
android:layout_height="407dp"
android:layout_weight="1.52"
android:choiceMode="singleChoice" />
</LinearLayout>
Any advices?
Thanks a lot!
I believe the following attribute is the problem:
android:textIsSelectable="true"
When this is set to true for an EditText View, it allows text in the EditText to be selected, but it disallows editing of the text, which is why the keyboard doesn't show.
If you just want to allow normal copy/paste procedures, you don't need to set this.
I think you might have forgotten to add this to your activity, in your AndroidManifest.xml file:
<activity android:name="your_activity_name"
...
android:windowSoftInputMode="adjustPan"
...>
More information
Try removing both android:clickable and android:textIsSelectable attributes
I am working on an app and have a problem.
I have an vieww like the image below with an image and an edittext field the right position. But when i click on the edittext field and it gets the focus it pushes the other view up.
I have the full screen flag and if i dont use that it works perfect and the image keeps theire position and dont pushed up. I need that with full screen flag.
Is there someone who have some example or can help me. I have used the 'windowSoftInputMode' with all the posibles values.
Here my layout code and examples how it now works and how it needs to be.
xml layout source:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical|none" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- layout for images -->
<RelativeLayout
android:id="#+id/imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="top" >
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/image"
android:contentDescription="TODO"/>
</RelativeLayout>
<!-- layout for edit text -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_alignTop="#id/imageview"
>
<EditText
android:id="#+id/tekstbox"
android:imeOptions="flagNoExtractUi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Here is the image how i start in the activity
When i click in the edittext field i want my view to react as below:
But when the edittext gots focus it pushes everything up like below:
Does someone know how to solve this with the fullscreen flag on?
Thanks.
User this line of code in your Manifest.xml. In the activity where the problem is occuring
<activity
android:windowSoftInputMode="stateVisible|adjustNothing">
</activity>
Add the below line in your manifest file in activity tag:
android:windowSoftInputMode="adjustResize"
and add ScrollView in your layout file like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:fillViewport="true"
android:orientation="vertical"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical|none" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- layout for images -->
<RelativeLayout
android:id="#+id/imageview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="top" >
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/image"
android:contentDescription="TODO"/>
</RelativeLayout>
<!-- layout for edit text -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:layout_alignTop="#id/imageview"
>
<EditText
android:id="#+id/tekstbox"
android:imeOptions="flagNoExtractUi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Add the below line in your manifest file in activity tag:
android:windowSoftInputMode="adjustPan|stateHidden"
My xml code is here,
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/mainlayout" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="#+id/toplayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="100dp"
android:src="#drawable/bg" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:id="#+id/bottomlayout">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter value" />
</LinearLayout>
when i execute , i got like this,
after execute , when i enter the value on edit text ,the virtual keyboard is open and the entire mainlayout is scroll up, i got like this
But i except , the top layout not to scroll up , only the bottom layout or textview scroll up. i expect like this,
how to scroll only the edit view when open the virtual keyboard. ?
Try this; maybe it is useful. Adjust the manifest file
<activity
android:windowSoftInputMode="adjustResize"
android:name=".youractivity" android:label="#string/app_name" >
#Ganesh you change manifest like above your Activity code also working
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/toplayout">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<EditText
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:hint="Enter value" />
</RelativeLayout>
</LinearLayout>
Hi I'm designing a navigation application for as a Uni project. I'm having problems with getting the button to stay underneath the soft keyboard when it appears. I'm using LinearLayout as a frame. I've searched a lot and tried different techniques but nothing seems to work.
a picture of the problem
Here is my XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<requestFocus />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical" >
<EditText
android:id="#+id/navi_searchfield1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Current location" >
</EditText>
<ListView
android:id="#+id/navi_listview1"
android:layout_width="fill_parent"
android:layout_height="0dp">
</ListView>
<EditText
android:id="#+id/navi_searchfield2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Destination" />
<ListView
android:id="#+id/navi_listview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<Button
android:id="#+id/start_navigation"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="#drawable/start"
android:textColor="#ffffff"
android:text="Start navigation" />
</LinearLayout>
Add android:windowSoftInputMode="adjustPan" to your activity in AndroidManifest.xml as:
<activity
android:windowSoftInputMode="adjustPan"
.
.
.
</activity>
This will prevent SoftKeyboard from moving your button, giving you an output like:
You can use the button even though the keyboard is shown by scrolling on the screen. But I think you probably can't show the keyboard above the button because I worked with SoftKeyboard and it uses:
android:layout_alignParentBottom="true"
So, you can only keep your layout safe from being pushed by SoftKeyboard.