简体   繁体   English

为什么我的应用在设计模式和仿真器上看起来不同?

[英]Why does my app look different on design mode and emulator?

I am programming an app and have custom design for my app, the problem is the ui looks perfect in design mode but in run-time mode (on emulator and real device) it looks different. 我正在为一个应用编程,并为我的应用进行了自定义设计,问题是用户界面在设计模式下看起来很完美,但是在运行时模式下(在仿真器和真实设备上)它看起来有所不同。 Any clue why??? 任何线索为什么??? Thanks to everyone. 谢谢大家。

My accomplish it to make the ui in emulator look the same as in design mode. 我完成了这项工作,以使模拟器中的ui看起来与设计模式下的ui相同。

在此处输入图片说明

Here's some code: 这是一些代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/bg"
    android:weightSum="8">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".8">
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".8">
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_marginLeft="50sp"
        android:layout_marginRight="50sp"
        android:padding="4dp"
        android:layout_weight=".8">
    <Button
        android:text="Start"
        android:textColor="#0495d4"
        android:textAllCaps="false"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btnStart"
        android:layout_gravity="center" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_marginLeft="50sp"
        android:layout_marginRight="50sp"
        android:padding="4dp"
        android:layout_weight=".8">
    <Button
        android:text="Followings"
        android:textColor="#0495d4"
        android:textAllCaps="false"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btnFollowings"
        android:layout_gravity="center" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".8">
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_weight=".8"
        android:orientation="horizontal"
        android:weightSum="3">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".2"/>
        <LinearLayout
            android:layout_width="0dp"
            android:padding="2sp"
            android:layout_height="fill_parent"
            android:layout_weight="2.6">
    <EditText
        android:hint="Pin Code"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:textSize="16dp"
        android:textColor="@android:color/white"
        android:fontFamily="sans-serif-medium"
        android:textColorHint="@android:color/white"
        android:backgroundTint="@android:color/white"
        android:id="@+id/txtPinCode" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".2"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"


        android:layout_weight=".8"
        android:orientation="horizontal"
        android:weightSum="3">
        <LinearLayout
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight=".8"/>
        <LinearLayout
            android:layout_width="0dp"
            android:padding="10sp"
            android:gravity="center"

            android:layout_height="fill_parent"
            android:layout_weight="1.4">
    <Button
        android:text="Verify Pin"
        android:textColor="#0495d4"
        android:textAllCaps="false"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btnSavePin" 
        android:layout_gravity="center" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".8"/>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2.4">

    </LinearLayout>
</LinearLayout>

The reason why the designs look different is that the emulator's screen configuration is different to that which is used to render the design preview. 设计看起来不同的原因是仿真器的屏幕配置与用于呈现设计预览的屏幕配置不同。

In the dropdown (see screenshot 1 ) of the layout editor try to find a configuration that matches your emulated device both in dimension and dpi. 在布局编辑器的下拉列表中(请参见屏幕截图1 ),尝试找到在尺寸和dpi上都与您的仿真设备匹配的配置。 That way the preview will be more accurate. 这样,预览将更加准确。

设备选择器

To find out which screen configuration your emulator has just go to the device manager (screenshot 2 ) and refer to the resolution column. 要找出您的仿真器具有哪种屏幕配置,只需转到设备管理器(屏幕截图2 ),然后参考分辨率列。

装置经理

On different devices (device emulators) and on different versions of android different values ​​of standard styles (textView, input field and so on). 在不同的设备(设备仿真器)和不同版本的android上,标准样式的不同值(textView,输入字段等)。 The designer shows everything verbatim, the device widgets are mixed with styles from the standard android library (a specific version) 设计师逐字显示所有内容,设备小部件与标准android库(特定版本)中的样式混合在一起

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的网站在Android模拟器和设备上看起来有所不同? - Why does my website look different in Android emulator and on devices? 为什么我的应用在模拟器中看起来不错,但在手机上却不行? - Why does my App look good in Emulator but not on the phone? 为什么设计看起来与 android studio 模拟器中显示的不同? - Why does the design look different than what's shown in emulator in android studio? 为什么我的 Flutter 应用程序在 IOS 模拟器上看起来很好,但在 Android 上却溢出了? - Why does my Flutter app look fine on the IOS emulator but overflow on Android? 为什么我的listPreference对话框看起来不同? - Why does my listPreference dialog look different? 为什么我的启动器图标看起来不同? - Why does my launcher icon look different? 为什么设计(activity_main.xml)和实际应用看起来不同? - Why Design(activity_main.xml) and actual app look different? 为什么在将浏览器大小调整为完全相同的分辨率时,我的自适应设计在移动设备上看起来与在外观上有所不同? - Why does my responsive design look different on mobile than it does when I adjust the browser size to the exact same resolution? 为什么我的应用程序在手机上崩溃,但在AVD模拟器上却没有崩溃? - Why does my app crash in my mobile phone but not on AVD emulator? 为什么我的Android Studio预览看起来不同? - Why does my Android studio preview look different?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM