Android studio设计预览与运行时布局不同

Android studio设计预览与运行时布局不同,android,android-layout,Android,Android Layout,我展示了一个xml文件,如下所示: <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:paddingTop

我展示了一个xml文件,如下所示:

<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:paddingTop="16dp"
    android:paddingBottom="16dp"
    tools:context=".MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:background="@android:color/holo_red_dark"
        android:paddingLeft="8dp"
        android:paddingRight="8dp">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="8dp"
            android:paddingBottom="8dp">

            <TextView
                android:textAppearance="@android:style/TextAppearance.Large"
                android:id="@+id/price_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="50 234 qwerty."/>

            <TextView
                android:id="@+id/discount_text"
                android:layout_width="wrap_content"
                android:textAppearance="@android:style/TextAppearance.Small"
                android:layout_height="wrap_content"
                android:text="qwerty 12 3456."/>

        </LinearLayout>

    </RelativeLayout>

</RelativeLayout>

但应用程序运行时显示的结果与预览窗口不同。尤其是底部的文字似乎被剪掉了。我在应用程序和预览窗口中都有相同的主题设置,我使用相同的设备。设备上的文本大小正常。但它仍然不同——为什么

试试这个

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_red_dark"
    android:paddingLeft="8dp"
    android:paddingRight="8dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="8dp"
        android:paddingTop="8dp" >

        <TextView
            android:id="@+id/price_text"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="50 234 qwerty."
            android:textAppearance="@android:style/TextAppearance.Large" />

        <TextView
            android:id="@+id/discount_text"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="qwerty 12 3456."
            android:textAppearance="@android:style/TextAppearance.Small" />
    </LinearLayout>
</RelativeLayout>



在android studio中,预览的api是19,然后在模拟器中,api是18。看起来,
@android:style/textpearance.Large
small
的尺寸是不同的


让我们在预览和执行代码中使用相同的api。

除了actionbar标题文本之外,不会改变任何内容。这不是关于正确的布局,而是关于差异。