【问题标题】:Android Application launches with wrong resolutionAndroid 应用程序以错误的分辨率启动
【发布时间】:2014-07-11 15:17:11
【问题描述】:

所以我一直在构建一个 Android 应用程序,并在实际在虚拟或真实设备上进行测试之前编写了很多代码。我第一次测试它是在 Nexus One 虚拟设备中。它运行良好。问题是,从那时起,该应用程序在其他所有设备上以完全相同的分辨率启动 Nexus One,无论是否虚拟。我尝试在 Nexus 4 (VD)、Nexus 7 2013 和 2012 (VD) 以及真实设备 Acer Iconia A1-830 上启动它。 Views 和 ActionBar 都出现“缩放”,就好像它用 Nexus One 分辨率填充屏幕一样,我不知道为什么会发生这种情况,或者我可以在哪里更改该设置(如果有的话)。 在 Nexus One 中运行的应用程序截图:

在 Nexus 4 中运行的应用的屏幕截图(在 7 中类似,在真实设备中更明显):

当然,在这些屏幕截图中它看起来并没有太大的不同,但它的比例是错误的。

我的 MainActivity 布局 xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.tinkerstudio.todolist.gui.MainActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/btn_insert_todo_txt"
        android:id="@+id/btn_insert_todo"
        android:onClick="insertTODOBtnClicked"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/listview_todo_list"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/btn_insert_todo" />


</RelativeLayout>

dimens.xml 都是默认设置

w820dp:

<resources>
    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
         (such as screen margins) for screens with more than 820dp of available width. This
         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
    <dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

“常规”:

<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
</resources>

我该如何解决这个问题?

【问题讨论】:

    标签: android layout android-studio screen-resolution


    【解决方案1】:

    虽然没有报告,但这似乎是 Android Studio 中的一个错误 重新制作项目解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-08
      相关资源
      最近更新 更多