I am creating an app which requires a different layout for screen sizes. I have been searching for a while and have already added the screen specifications into my manifest, and created a different layout folder for each screen size.
我正在创建一个应用程序,它需要不同的屏幕尺寸布局。我已经搜索了一段时间,并且已经将屏幕规范添加到清单中,并为每个屏幕大小创建了一个不同的布局文件夹。
When I run the emulator from android studio with a tablet emulator it runs the layout-xlarge
files as needed. However in all other cases it runs just layout
files.
当我使用平板电脑模拟器运行android studio的模拟器时,它会根据需要运行layout-xlarge文件。但是在所有其他情况下,它只运行布局文件。
This is a problem for me because I need the layout-large
files to work also.
这对我来说是一个问题,因为我需要布图-大文件也工作。
I was wondering if this has to do with my code or if this is an emulator problem?
我想知道这是否与我的代码有关还是这是一个模拟器问题?
edit: android manifest
编辑:android清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pckg_name">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
<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:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
example xml in layout-large
示例xml layout-large
<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:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@mipmap/background1">
<Button
android:id="@+id/create_an_account_initial_page"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large screen"
android:textSize="17sp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:background="@drawable/button_rectangle_red"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="31dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"/>
</RelativeLayout>
1 个解决方案
#1
1
Check your emulated devices sizes, refer to the below:
检查您的仿真设备尺寸,请参阅下面:
xlarge screens are at least 960dp x 720dp
xlarge屏幕至少有960dp x 720dp。
large screens are at least 640dp x 480dp
大屏幕至少是640dp x 480dp
normal screens are at least 470dp x 320dp
正常屏幕至少是470dp x 320dp
small screens are at least 426dp x 320dp
小屏幕至少是426dp x 320dp
That will ensure it is using the right or wrong setting.
这将确保它使用了正确或错误的设置。
Try renaming the layout
folder to layout-normal
尝试将布局文件夹重命名为layout-normal。
#1
1
Check your emulated devices sizes, refer to the below:
检查您的仿真设备尺寸,请参阅下面:
xlarge screens are at least 960dp x 720dp
xlarge屏幕至少有960dp x 720dp。
large screens are at least 640dp x 480dp
大屏幕至少是640dp x 480dp
normal screens are at least 470dp x 320dp
正常屏幕至少是470dp x 320dp
small screens are at least 426dp x 320dp
小屏幕至少是426dp x 320dp
That will ensure it is using the right or wrong setting.
这将确保它使用了正确或错误的设置。
Try renaming the layout
folder to layout-normal
尝试将布局文件夹重命名为layout-normal。