how to solve orientation issue?
I want to make 480x800, 600x800, 600x1024 and 800x1280 resolution layouts.
i have to show both orientation(portrait and landscape) with resolution 600x800, 600x1024 and 800x1280 and resolution 480x800 show only landscape mode.
Right now it is showing both orientation mode.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nga.swp" and开发者_StackOverflow中文版roid:versionCode="1" android:versionName="1.0">
<supports-screens android:resizeable="true"
android:largeScreens="true" android:normalScreens="false"
android:smallScreens="false" android:anyDensity="true" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PhraseListActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" android:windowSoftInputMode="adjustPan" />
<activity android:name=".ViewActivity" android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-sdk android:minSdkVersion="8" />
</manifest>
my issue is how i am able to show landscape mode only with resolution 480x800. what changes i have to do in my menifest file.
The best way to have conditional layouts is by using qualified directory names inside the /res directory.
But in your case, you would need to change the android:screenOrientation of your activity. Alas, it is in the manifest and it does not seem to be setable in your activity layout.
So, I guess you have to use code in your activity onCreate.
First get the screen dimension using:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Then conditionally adapt screen orientation using :
if((width != 480) && (height !=800))
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
See ActivityInfo.screenOrientation
for further orientation modes.
I think you should make
layout-land
layout
put your xml in that.
480x800, 600x800, 600x1024 and 800x1280 resolution layouts for that..
you should make drawable-ldip, drawable-mdip, drawable-hdip
folder and put your images in that.
Android direct take & differentiated resolution.
First of all check your device resolution by using:
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Then get the device's height & width using display.getHeight()
and display.getWidth()
.
It is much easier to do the next operations.
You can use OrientationListener
in order to check the orientation.
精彩评论