设计可以在Android Studio预览中完美显示,但不能在真实设备中显示

时间:2018-09-20 08:08:27

标签: android xml android-layout android-studio android-designer

我正在开发一个Android应用程序,并且试图在Android Studio中实现Image in Android Studio Preview 之类的设计版式

但是当我在真实设备上运行它时,它显示的布局类似于Design In Real Device

在Android Studio中,我使用Nexus 4来设计布局,而我的手机分辨率为720x1280。 这是我的xml代码

<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.usmanali.childsafety.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="275sp"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="3dp">

    <ImageView
        android:id="@+id/imgschool"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/im"
        android:contentDescription="@string/todo" />
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="115sp"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="278dp">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/download" />
</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="110sp"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="393dp"
    tools:ignore="MissingConstraints">

    <Button
        android:id="@+id/btnlogin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/btnregister"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:text="@string/login"
        android:textStyle="bold"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="291dp" />

    <Button
        android:id="@+id/btnregister"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:text="@string/sign_up"
        android:textStyle="bold"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="340dp" />
</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

尝试一下

test_df = spark.createDataFrame([("a","b",[1,]),("c","d",[0,])], ("alias","value","number"))
test_df.select("alias","value",when(array_contains(test_df.number,0),"0").otherwise(test_df.number)).show()