I have a layout in an app with parallax effect on an edittext, my problem is **when I tap on the edittext softkeyboard hides my editext?**Can anybody please help me for this, I have searched for it and found about "WindowsoftInputmode" which is not working in my case.
Code in manifest
<activity
android:name="one.tusk.stush.activities.NewPostDetailActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|adjustPan" >
You should only use android:windowSoftInputMode="adjustResize".
If this is not enough, you might need to add the property android:fitsSystemWindows="true" to the root layout containing your EditText.
Try this in your manifest,
<activity
android:name=".rapcalsy.MainActivity"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Change your layout according this,
dont miss the line which is
android:isScrollContainer="true"
<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:isScrollContainer="true"
android:orientation="vertical">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#000000"
android:padding="0dp"
android:stretchColumns="*">
...
</TableLayout>
</ScrollView>
Please try this out.
Set an android:softInputMode attribute to adjustResize in Manifest and put the parent layout inside a ScrollView. Hope this helps.
I tried a bit with as you said then i got this working
edit the your manifest file
<activity
android:name="one.tusk.stush.activities.NewPostDetailActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible" >
and then add below line of code in oncreate of java class
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
So that keyboard will not shown to you directly/always
Related
When I focus on another element in my app (landscape), the keyboard goes over my view that should be displayed, which I do not really want.
Code:
<activity
android:name=".activity.ReportsEditActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="#string/title_activity_reports_edit"
android:parentActivityName=".activity.MainActivity"
android:windowSoftInputMode="adjustPan|stateVisible">
</activity>
The edittext:
<EditText
android:id="#+id/report_template_grid_multi_line_edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/grid_element_top_and_bottom_padding"
android:layout_marginEnd="#dimen/grid_padding"
android:layout_marginStart="#dimen/grid_padding"
android:layout_marginTop="#dimen/grid_element_top_and_bottom_padding"
android:gravity="top|start"
android:inputType="textMultiLine"
android:paddingBottom="#dimen/grid_element_top_and_bottom_padding"
android:paddingEnd="#dimen/grid_element_top_and_bottom_padding"
android:paddingStart="#dimen/grid_element_top_and_bottom_padding"
android:paddingTop="#dimen/grid_element_top_and_bottom_padding"
android:scrollbars="vertical"
android:textColor="#color/darkGray"
android:textSize="#dimen/grid_text_size_small" />
This is fine:
But this is not fine, this occurs after clikcing on the edittext above the previous one when the keyboard is open
You could try android:windowSoftInputMode="adjustResize"
<activity
android:name=".activity.ReportsEditActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="#string/title_activity_reports_edit"
android:parentActivityName=".activity.MainActivity"
android:windowSoftInputMode="adjustResize">
</activity>
I have a button at the bottom of the screen and I want it to stay down even if soft keyboard goes up, but currently it goes up with soft keyboard. I tried to align the button to bottom but with no success.
Here is the code (buttons are within id/activity_form_button_frame):
<RelativeLayout>
<RelativeLayout
android:id="#+id/activity_form_button_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageButton
android:id="#+id/activity_form_next_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/black"
android:src="#drawable/next_btn_drawable"
android:scaleType="fitCenter"
android:padding="5dp"
/>
<Button
android:id="#+id/activity_form_sumbit_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#android:color/black"
android:text="SUBMIT"
android:textColor="#color/buttonBlue"
android:visibility="gone"
android:padding="15dp"
style="#android:style/TextAppearance.Large"/>
</RelativeLayout>
<FrameLayout
android:id="#+id/activity_form_fragmentcontainer"
android:layout_below="#id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/activity_form_button_frame"/>
</RelativeLayout>
In AndroidManifest.xml, set android:windowSoftInputMode="adjustPan" to your activity.
Like this.
<activity
android:windowSoftInputMode="adjustPan">
Or:
<activity
android:windowSoftInputMode="adjustPan|adjustResize">
Also you can do this Programmatically.
Use this code in onCreate() method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Check this for Reference.
Try this
<activity
android:windowSoftInputMode="adjustPan">
or in code
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
try this....
<activity
android:windowSoftInputMode="adjustPan">
Try add in manifest to your activity attribute android:windowSoftInputMode.
Set it to adjustResize or adjustPan. One of these will work.
Inside your manifest file under your activity tag just add this line.
android:windowSoftInputMode="stateHidden|adjustResize"
For Example,
<activity
android:name="packagename.ClassName"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
And you are good to go.
Change at your AndroidManifest file and at activity to add property like
android:windowSoftInputMode="adjustResize"
to this direct to open keyboard to above button.
In your manifest file under activity tag add the following line.
android:windowSoftInputMode="adjustPan|adjustResize"
In your AndroidManifest.xml try this code:
<activity
android:name="com.facebook.FacebookActivity"
android:windowSoftInputMode="adjustPan|adjustResize"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
In my case, I was using <item name="android:windowFullscreen">true</item> in my theme. It was creating problem and I used android:windowSoftInputMode="adjustResize" along with that.
You can use android:layout_alignParentBottom="true" for that.
I want to create an android application which has 3 sliding tab panel and each of them will 5 button (save,new,delete,exit..).
What I want is exactly as follow:
I created sliding tab panel.And for 5 button, I added split action bar.But It works as normal split action bar.My AndroidManifest.xml is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.belsoft.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:uiOptions="splitActionBarWhenNarrow"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Where is my wrong?
To implement splitActionBar:
Just add android:uiOptions="splitActionBarWhenNarrow" to your activity tag in theAndroidManifest.xml like this...
`<activity
android:name=".MainActivity"
android:uiOptions="splitActionBarWhenNarrow">`<br>
You can read more here and here
NOTE: It is available ONLY for handset devices with a screen width
of 400dp.
To create a custom bottom toolbar:
If you want to set it for all devices, please check my answer (find a post starting with Creating custom bottom toolbar) here:
Creating custom bottom toolbar
I've already created a simple app which should demonstrate you how to
begin
Creating a custom ViewGroup
Here's my activity_main.xml layout file:
<?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"
android:padding="0dp"
tools:context="com.example.piotr.myapplication.MainActivity">
<LinearLayout
android:id="#+id/show_pdf"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#color/primary_material_light"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_cut_mtrl_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_copy_mtrl_am_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_selectall_mtrl_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_paste_mtrl_am_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_share_mtrl_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_selectall_mtrl_alpha"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/abc_ic_menu_moreoverflow_mtrl_alpha"/>
</LinearLayout>
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="75dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
</RelativeLayout>
As you can see my parent ViewGroup is RelativeLayout, which simply
allows me to create a view at the bottom of screen.
Notice that I set layout padding to zero (I think: setting layout
margin to zero here is not necessary, the same effect). If you'd
change it, the toolbar won't use full width and it won't stick with
bottom of the screen.
Then I added a Linear Layout with hardcoded height which is:
android:layout_height="40dp"
I wanted it, that my bottom toolbar would take full available width so
I set it as match_parent.
Next, I added some ImageButton views with images from Android
library.
There you have two possibilities:
if you really want to have a toolbar like in above example just remove in every ImageButton view this line:
android:layout_weight="1"
After removing weights and some buttons you would get a view pretty
similar to expected:
if you want to take the full width and make every button with the same size use in your project weight as in this mine example.
Now let's go to my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.piotr.myapplication"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:windowSoftInputMode="stateVisible|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
In that file I'd added as you can see only one additional line:
android:windowSoftInputMode="stateVisible|adjustResize">
to make sure that device keyboard won't hide my custom bottom toolbar.
From: How to add a bottom menu to Android activity
If you have any question please free to ask.
Hope it help
I have an android program with 2 layouts. The first layout is Login. When the login is started first, I have no problem. When I try to change in AndroidManifest from login to splash layout, I got an error. The error is like the title of this posts.
In this android manifest, I change my code from :
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".Login"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
to :
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name=".Splash"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Here is the layout for login:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:orientation="vertical"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".Login">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Your total is 0"
android:textSize="45dp"
android:gravity="center"
android:id="#+id/tvDisplay"
/>
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Add One"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/bAdd"
android:textSize="20dp"/>
<Button
android:layout_width="250dp"
android:layout_height="100dp"
android:text="Substract One"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/bSub"
android:textSize="20dp"/>
And here the layout of splash:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#drawable/sertifikat"
tools:context=".Splash"></LinearLayout>
And structure of my code :
Log in logcat:
Here splash.java
How can I fix my code?
Hey You missed some small things
Here is a small example from your code
on Github that i wrote
This is running example of your code
Other than the ending tags
The <intent-filter>
should only be one
most probably the problem lies in your #drawable
as well as look at these tutorials they are great
http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/
Obviously,you have lost a character '/' in the splash layout at the end.
You are missing the closing tag of your LinearLayout in splash.xml. Add </LinearLayout> to the end of the file. You also might want to consider using an ImageView with android:scaleType="centerCrop" instead of using a LinearLayout with a background. Using android:background will stretch to fit the size of the screen, which can give a different aspect ratio on different devices, whereas an ImageView will scale it to maintain the aspect ratio (depending on the scaleType).
Also, a LinearLayout is not appropriate for a single image, since it is meant to be a container for other views.
For better performance I recommend you to follow this :
http://www.cutehacks.com/blog/2014/01/13/splash-screens
If you use an high end device you won't see a big difference, but for common devices you will see an huge improvement
I have looked Here but am still unable to tackle my problem.
I have recently jumped into android (headfirst) and have been messing around. I would like my application to only run in Landscape mode no matter which way the screen is tilted.
My home screen is basically a page with a background and a few buttons that are aligned on the right side.
Here is my XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft = "450px"
android:paddingRight = "60px"
android:paddingTop="25px"
//I have tried adding orientation commands here like the one below??
android:screenOrientation="landscape"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background = "#drawable/sign"
>
<Button
android:id="#+id/Button1"
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Button1"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="#+id/Button2"
android.layout_height="60px"
android.layout_width="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="Button2"/>
add this line in your manifest.xml file.
<activity android:name=".activity" android:screenOrientation="portrait"></activity>
if you want only landscape orientation then change landscape instead of portrait
see this How to set android show vertical orientation?
Add the following property all the activites in your manifest file:
android:screenOrientation="landscape"
for example:
<activity android:name=".MainActivity" android:screenOrientation="landscape" " >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
you can add this property in your application tag also in the manifest file .
hope this help you to solve your issue.
You need to put android:screenOrientation="landscape" on the activity tag in your AndroidManifest.xml file.
Reference: http://developer.android.com/guide/topics/manifest/activity-element.html