【问题标题】:Android layout for Nexus4 vs Nexus 7Nexus4 与 Nexus 7 的 Android 布局
【发布时间】:2014-12-15 11:39:53
【问题描述】:

我在 Nexus 4 中预览我的 Android 应用 :)。在这里

但是当我尝试在 Nexus 7 模拟器上预览它时,:(

我认为我在支持我的游戏中的多个屏幕时遇到了问题。 我的问题是,如何让它在 nexus 7 或 10 或任何其他设备上看起来更大?

顺便说一句,我将图像(board.png、small_hole.png、big_hole.png 和 bg.png)放在 drawable-xhdpi 文件夹中(我使用的是 Android Studio)

您认为我在 xml 文件中使用了错误的布局或属性吗?我的代码有问题吗?

这是我的 xml 布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg.png>

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/board"
        android:orientation="horizontal" >

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/big_hole" >
            </ImageView>
        </FrameLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center_vertical">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginBottom="2dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/small_hole" >
                </ImageView>

                // paste 6 more ImageViews here

            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginTop="7dp">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/small_hole" >
                </ImageView>

               // paste 6 more ImageViews here

            </LinearLayout>

        </LinearLayout>

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginRight="20dp" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitCenter"
                android:background="@drawable/big_hole" >
            </ImageView>

        </FrameLayout>

    </LinearLayout>

</RelativeLayout>

谢谢你们..

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    Nexus 4 访问drawable-xhdpi 资源和

    Nexus 7 访问 drawable-large-tvdpidrawable-sw600dp-tvdpi 资源。

    Nexus 10 访问 drawable-xlarge-xhdpidrawable-sw720dp-xhdpi 资源。

    你应该调整你的图片大小,然后你应该放在各自的文件夹中。

    Nexus 4 的尺寸为 4.7 英寸 (768*1280),而 Nexus 7 的尺寸为 7 英寸 (800*1280)。

    更多信息:

    Different resolution support android

    Application Skeleton to support multiple screen

    Is there a list of screen resolutions for all Android based phones and tablets?

    【讨论】:

    • 欢迎好友..使用drawable-sw720dp-xhdpi 连接 10
    【解决方案2】:

    尝试将您的图像放在 res/mdpi 中,它们将被拉伸以适应更大的屏幕(hdpi、xhdpi) (如果我没记错的话,hdpi 和 xhdpi 的修饰符是 x1.5 和 x2)。

    或者,您可以为更大的屏幕创建一个布局文件夹,即。 layout-sw720dp 并在那里创建一个新的布局文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      相关资源
      最近更新 更多