小编Dhr*_*hra的帖子

平板电脑用户界面无法在我的应用上运行

我正在尝试创建一个应用程序,它有两个不同的平板电脑和手机用户界面,我正在使用片段来实现这一点.我为每个平板电脑和手机布局创建了两个单独的xml文件,两者都称为activity_main.xml,电话布局放在res/layout文件夹中,平板电脑布局放在res/layout-sw600dp文件夹中.

但是,当我尝试在Nexus 10模拟器(Android Studio)上运行我的应用程序时,它会自动转到默认的手机布局.该应用程序不会崩溃或任何东西,但它只是在手机用户界面中运行,当它应该在平板电脑用户界面运行时.我不知道这个错误的来源是什么,所以任何帮助将不胜感激.

这是一个更新,我尝试将文件夹重命名为res/layout-large-mdpi,但仍然没有发现任何变化.是否有可能与仿真器有关?

这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidattack.www.sunshine" >

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.androidattack.www.sunshine.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.androidattack.www.sunshine.DetailActivity"
            android:label="@string/title_activity_detail"
            android:parentActivityName="com.androidattack.www.sunshine.MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.androidattack.www.sunshine.MainActivity" />
        </activity>
        <activity
            android:name="com.androidattack.www.sunshine.SettingsActivity"
            android:label="@string/title_activity_settings"
            android:parentActivityName="com.androidattack.www.sunshine.MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.androidattack.www.sunshine.MainActivity" />
        </activity>
        <provider
            android:authorities="com.androidattack.www.sunshine"
            android:name=".data.WeatherProvider" />
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

sw600dp布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="?android:attr/dividerHorizontal"
    android:baselineAligned="false"
    tools:context="com.androidattack.www.sunshine.MainActivity">

    <fragment
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:name="com.androidattack.www.sunshine.ForecastFragment"
        android:id="@+id/fragment_forecast"
        android:layout_gravity="center_vertical" …
Run Code Online (Sandbox Code Playgroud)

java android android-layout android-fragments

7
推荐指数
2
解决办法
1023
查看次数

标签 统计

android ×1

android-fragments ×1

android-layout ×1

java ×1