Keep layout changes persistent after changing orientation in android - android

I am changing visibility of button at run time.
but when ever I am changing orientation I am getting default layout defined in XML file
So what should I do to keep the changes done in layout at runtime
Thanks...

not sure if it could work. adding the following into your AndroidManifest.xml which can prevent the activity from being restart when you change orientation.
activity ..........
android:configChanges="orientation|screenSize"

Inside file:
AdroidManifest.xml
<activity .. android:configChanges="orientation|screenSize" />
It works for me very well. That's what I was looking for.
Now, my Changes stay alive after I changed the screen-layout-orientation.
Thank you Ksharp, very much.

Related

how to move the entair screen up when keyboard enabled?

I want to scroll up the entair screen up when keyboard opened like below.How to do that?
https://www.screencast.com/t/34JwVngLdYbU
Apply android:windowSoftInputMode="adjustPan|adjustResize" with activity tag in manifest file.
android:windowSoftInputMode="adjustPan|adjustResize"
and put complete layout in LinearLayout and ScrollView & define
layout_height="0dp"
layout_weight="1"
Note: No view have parameter layout_height="match_parent"
I had also same issue just adding a single line to my AndroidManifest file's activity.
<activity
android:name=".activities.YOURACTIVITY"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateVisible"/>
If you want keyboard should appear with start Activity then use stateVisible otherwise use stateHidden.
Here the most important value is the adjustResize. This will shift the whole UI up to give room for the softkeyboard.

How do I avoid this meshing of textview and buttons?

Issue:
I have seen this overlap anytime I have a button under a textview or edittext. If I try to add text to one of these, the keyboard forces the buttons to raise. What causes this overlap and how can I avoid it?
Try android:windowSoftInputMode="adjustNothing" in your AndroidManifest.xml file for the activity you're using the layout, for example:
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustNothing">
For more info go to the following link: http://developer.android.com/reference/android/R.attr.html#windowSoftInputMode
Change RelativeLayout to other type of layout or specify different android:windowSoftInputMode in your manifest for this activity.

Android Screen is not moving up while entering text in EditText

Already i used adjust pan in manifest file--i am using five edit text field--like register form..if i enter text in edit text-- after screen will move up--but for me screen not moving--
anyone guide me--
Pretty much attach the following in your manifest:
android:windowSoftInputMode="adjustResize"
To get a better understanding see link below:
http://developer.android.com/training/keyboard-input/visibility.html#Respond
try this line in your manifest file inside activity tag, it may help
android:windowSoftInputMode="adjustPan|adjustResize"

The theme in manifest.xml

I change
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
to
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
But why it can not change orientation?
If use android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen", it can change orientation.
But if change to another one, it can't.
I try it in Android 2.3.4.
But in Android 4.0.2, it works success on change orientation.
Why and how to avoid it?
Add
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
to each activity you need.

How to move the layout up when the soft keyboard is shown android

I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up or above the keyboard when it appears?
I do not want to use a ScrollView, just want to implement it without scrolling down. How can that be done?
Set windowSoftInputMode property to adjustPan and adjustResize
<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>
Try this in the android manifest file corresponding to the activity.
<activity android:windowSoftInputMode="adjustPan"> </activity>
Use this code in onCreate() method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
only
android:windowSoftInputMode="adjustResize"
in your activity tag inside Manifest file will do the trick
Put this line in activity declaration time in manifest.xml
<android:windowSoftInputMode="adjustPan">
android:fitsSystemWindows="true"
add property on main layout of layout file and
android:windowSoftInputMode="adjustResize"
add line in your Manifest.xml file on your Activty
its perfect work for me.
I somehow achieved this by knowing the status of the soft keyboard on the device. i move the layout to y position when the keyboard is shown and moved back to its original position when not shown. this works fine, followed this guidelines.
Put this in your activity declaration in manifest file
<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>
or if you want you can add in onCreate() method of your activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
This is all that is needed:
<activity android:windowSoftInputMode="adjustResize"> </activity>
I solve this by adding code into manifest:
<activity android:name=".Login"
android:fitsSystemWindows="true"
android:windowSoftInputMode="stateHidden|adjustPan"
</activity>
Accoding to this guide, the correct way to achieve this is by declaring in your manifest:
<activity name="EditContactActivity"
android:windowSoftInputMode="stateVisible|adjustResize">
</activity>
When the softkeyboard appears, it changes the size of main layout, and what you need do is to make a listener for that mainlayout and within that listener, add the code scrollT0(x,y) to scroll up.
If you are working with xamarin, you can put this code
WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize in activity attribute of the MainActivity class.
For example, now the activity attribute will look like below
[Activity(WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
//some code here.
}
You should use
android:windowSoftInputMode="adjustPan|stateHidden"
in your AndroidManifest.xml file where you are declaring your activity. This will adjust your layout contents, when keyboard is shown in the layout.
Make use of Relative layout it will adjust the view so that you can see that view while typing the text
This works like a charm for me
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
This will definitely work for you.
android:windowSoftInputMode="adjustPan"

Categories

Resources