Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何解决定位问题?_Android_Orientation - Fatal编程技术网

Android 如何解决定位问题?

Android 如何解决定位问题?,android,orientation,Android,Orientation,我想制作480x800、600x800、600x1024和800x1280分辨率的布局 我必须以分辨率600x800、600x1024和800x1280以及分辨率480x800仅显示横向模式显示方向(纵向和横向) 现在它显示两种方向模式 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="c

我想制作480x800、600x800、600x1024和800x1280分辨率的布局


我必须以分辨率600x800、600x1024和800x1280以及分辨率480x800仅显示横向模式显示方向(纵向和横向)

现在它显示两种方向模式

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nga.swp" android: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> 

我的问题是如何仅以480x800分辨率显示横向模式。
我必须在我的menifest文件中进行哪些更改。

首先使用以下方法检查设备分辨率:

Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
然后使用
display.getHeight()
display.getWidth()
获取设备的高度和宽度

进行下一步操作要容易得多


您可以使用
OrientationListener
来检查方向。

首先,使用以下方法检查设备分辨率:

Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
然后使用
display.getHeight()
display.getWidth()
获取设备的高度和宽度

进行下一步操作要容易得多


您可以使用
OrientationListener
来检查方向。

拥有条件布局的最佳方法是在/res目录中使用限定的目录名

但在您的情况下,您需要更改活动的android:screenOrientation。唉,它在清单中,在活动布局中似乎不可设置

所以,我想您必须在创建活动时使用代码

首先使用以下方法获取屏幕尺寸:

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();
然后使用以下方法有条件地调整屏幕方向:

if((width != 480) && (height !=800))
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

有关更多方向模式,请参阅。

拥有条件布局的最佳方法是在/res目录中使用限定的目录名

但在您的情况下,您需要更改活动的android:screenOrientation。唉,它在清单中,在活动布局中似乎不可设置

所以,我想您必须在创建活动时使用代码

首先使用以下方法获取屏幕尺寸:

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();
然后使用以下方法有条件地调整屏幕方向:

if((width != 480) && (height !=800))
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

请参阅以了解更多方向模式。

我认为您应该

layout-land

layout
把你的xml放进去

480x800、600x800、600x1024和800x1280分辨率布局

您应该制作
可绘制ldip、可绘制mdip、可绘制hdip
文件夹,并将图像放入其中


Android direct take和差异化解决方案

我认为你应该

layout-land

layout
把你的xml放进去

480x800、600x800、600x1024和800x1280分辨率布局

您应该制作
可绘制ldip、可绘制mdip、可绘制hdip
文件夹,并将图像放入其中


Android direct take和差异化解决方案

如果我重新表述您的问题:您想仅限制480x800设备的横向模式?我必须显示屏幕分辨率(600x800、600x1024和800x1280)的方向,并且仅显示屏幕分辨率480x800的横向模式。现在它显示了所有分辨率的两种模式,并且除了480x800屏幕分辨率外工作良好。因为我只需要横向模式。@Laurent我怎样才能只限制480x800设备的横向模式。如果我重新表述你的问题:你想只限制480x800设备的横向模式?我必须显示屏幕分辨率的方向(600x800、600x1024和800x1280)和屏幕分辨率480x800的横向模式。现在它显示了所有分辨率的两种模式,并且除了480x800屏幕分辨率外工作良好。因为我只需要横向模式。@Laurent我怎样才能限制480x800设备的横向模式。