Screen rotation bug in actionbar - android

Hello everyone I am new in Sherlock Actionbar I am having a very strange problem in my sample application. The problem is that when I rotate to landscape from the portrait its behavior is normal but when I rotate back to portrait mode the layout does not change back to portrait mode.
Below are the screen shot of the problem I am facing.
OriginalScreen
Did rotation to Landscape
Again rotated back to original orientation i.e. Portrait Mode
As you can see that on the third picture the problem I am facing.
I am using the latest version of ActionbarSherlock library.
Edited
My manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.actionbar_sherlockexample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.actionbar_sherlockexample.MainActivity"
android:theme="#style/Theme.Sherlock"
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>
</manifest>
Thanks

This is an issue with emulator . If you will run it on real device , it will work fine .

Related

why my application does not start in landscape mode in some virtual devices

I have set screenOrientation to landscape in my AndroidManifest.xml. This works fine for most emulated devices in Android Studio.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".FullscreenActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:theme="#style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and in OnCreate
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_fullscreen);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
FullscreenActivity.context = getApplicationContext();
getSupportActionBar().hide();
But for Nexus 9 this doesn't work and my app stays in portait mode , which results in making my images distorted.
i would expect to be like this :
Startup orientation is portrait for both of them. I want to have a landscape only application
A solution i have found is to force a minimum aspect ratio to 1.3 with
android:minAspectRatio="1.3"
and to set
android:resizeableActivity="false"
With these options the activity starts within a part of the screen if it is in portrait mode and so the images do not get distorted

Android - Keyboard compresses my View

i'm working on an Android/iOS Application. When the Keyboard opens up for the login (username and password) all gets shrinked together and it looks like this:
normaly it should not be compressed. It should move up, and give me a clear view on what i'm typing.
Yes, so i don't know, what to do. I tried to work with percentages in the whole app (width/height) - maybe this is the reason, why my View gets not moved up but shrinked?
I looked around here at stack and found some suggestions like:
<activity
...
android:windowSoftInputMode="adjustPan">
</activity>
or adjustResize instead, but nothing of that worked for me. On iOS all works fine. What i want the view to do is that he just moves a bit up, and nothing gets resized.
I hope you can help me and if you need more information, please let me know, i'll update or comment my Question then.
Cordova 3.5
jQuery/jQuery-Mobile
Plugins: Camera/Console/Device/Dialogs/File-Transfer/File/inappbrowser/Splashscreen/Statusbar/vibration/geolocation/network-information
Eclipse with Genymotion emulator
Devices: Galaxy Note 10.1, 4.4.2; Xperia Z2 4.4.2
This is what my Androidmanifest looks like:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0" package="de.*****************.de" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:screenOrientation="portrait" android:label="#string/activity_name" android:launchMode="singleTop" android:name="********" android:theme="#android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustPan">
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>
I was stuck with the same problem, few days ago.
As you said, you have given height and width in percentage.
When the android keyboard appears the window is resized and its height is the screen size excluding the keyboard size.
Giving height in percentage to the main container of your page, (i.e. to the body tag) will shrink the height of your page when the keyboard appears,
Setting the min-height for the body tag once on document.ready worked for me.
$(function(){
$("body").css("min-height",$(window).height())
});
Add this In your manifest .I hope it will works. For more information Do Click HERE
android:windowSoftInputMode="stateUnchanged|adjustResize"

What is this empty black bar on the top called, and how can I get rid of it?

I am targeting api 10. On my droid maxx (4.4) there is this clickable but empty bar that appears on the side of the screen as seen here: http://i.stack.imgur.com/TSjmk.jpg . On my Nexus S (4.1.2) the bar is not present. On my friends Nexus 4 (4.4) he has a bar, but it contains the phones main buttons, the nexus 4 doesn't have off-screen buttons as mine does.
If I target api19, the bar goes away on my droid maxx, obviously thats not really a solution.
The bar renders on top of my application, and is just visually undesirable, so it's a real problem. What this bar is called and how I can get rid of it? Thanks.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.logicaldreams.edensharbor2"
android:versionCode="1"
android:versionName="1.0">
<application android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:allowBackup="true" >
<activity android:name="edensharbor2"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="keyboardHidden|orientation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

Androidmanifest.xml My Android App doesn't really fill the screen

I am trying to make my app fill the screen for normal displays, but this is the result when I boot it up on my Samsung Captivate i897: http://oi39.tinypic.com/2qamhqd.jpg
The screen's width is filled correctly, but not the vertical side. When I set android:anyDensity to "true" in androidmanifest.xml, the app's screen is fully shown, but only on the bottom-left corner of my screen: http://oi44.tinypic.com/29w7n9v.jpg
Can someone tell me how to make the app fit to screen?
Also, when an animation that takes up the whole screen is played, I get blurred and stretched images around the screen, as seen in the first screenshot link. This does not happen when I run it through moai.exe's OpenGL simulator (I am using moai-sdk and rapanui-sdk to develop my app. I imported them both into eclipse to create the apk file). I don't understand what could be the problem.
Here is how my androidmanifest.xml looks:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0"
package="com.gamefromscratch.moai">
<supports-screens
android:smallScreens="false"
android:normalScreens="true"
android:largeScreens="false"
android:xlargeScreens="false"
android:anyDensity="false"/>
<application
android:icon="#drawable/icon"
android:debuggable="true"
android:enabled="true"
android:persistent="false"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
<!-- Moai -->
<activity
android:name="MoaiActivity"
android:label="#string/app_name"
android:screenOrientation= "portrait"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.ziplinegames.moai.MoaiMoviePlayer"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<receiver android:name="com.ziplinegames.moai.MoaiLocalNotificationReceiver"></receiver>
<!-- EXTERNAL DECLARATIONS: Placeholder (DO NOT MOVE OR REMOVE) -->
</application>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
<!-- Moai -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- EXTERNAL PERMISSIONS: Placeholder (DO NOT MOVE OR REMOVE) -->
<uses-configuration android:reqTouchScreen="finger" />
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true" />
</manifest>
following attribute used for supports for multiple screen size, try this
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
To avoid image blurring problem you have to create separate images with more pixel for drawable-hdpi,drawable-xhdpi and drawable-xxhdpi folder.
you can create separate layout folder for different size layout-large,layout-xlarge.
try this also, this will solve orientation problem
android:screenOrientation="unspecified"
android:configChanges="keyboardHidden|orientation"
hope this will sove your problem.

How to fix layout orientation to vertical?

How to fix layout orientation to portrait and do not allow changing from portrait to landscape during run time?
In your AndroidMainfest.xml file find the tags of the activities you wish to lock to a given rotation, and add this attribute:
android:screenOrientation="portrait"
Use setRequestedOrientation() as shown:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
in your activity parameters in Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.statepermit" android:versionCode="1" android:versionName="1.0">
<application android:icon="#drawable/stateheader" android:label="#string/app_name">
<activity android:name=".statepermit" android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
android:screenOrientation="portrait"
If you want to freeze orientation at runtime, then you you can implement this:
Android: Temporarily disable orientation changes in an Activity
I use a similar approach and it works perfectly.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before
setContentView(R.layout.main);
If you want to fix the orientation of one Activity in your project, you have to open the Manifest.xml and put in the section of parameters of the desired Activity (before the closure of the first tag < activity…> ):
android:screenOrientation="portrait" if you want VERTICAL fixed orientation
android:screenOrientation="landscape" if you want HORIZONTAL fixed orientation
In your AndroidMainfest.xml just write this in your activity you declare,
If you want in layout vertical than use
android:screenOrientation="portrait"
If you want in layout landscape than use
android:screenOrientation="landscape"

Categories

Resources