如何确保版面显示与Android Studio设计模式下的显示完全相同?

时间:2018-07-23 23:50:12

标签: android-layout android-studio

我有一个包含以下内容的布局文件

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/back_to_register_login"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:background="#00e5ff"
    tools:context=".MainActivity"
    tools:theme="@style/AppTheme">

    <EditText
        android:id="@+id/username_edittext_register"
        style="@android:style/TextAppearance.Material.Widget.DropDownHint"
        android:layout_width="328dp"
        android:layout_height="47dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="24dp"
        android:background="@drawable/edittext_rounded"
        android:ems="10"
        android:hint="   Username"
        android:inputType="textPersonName"
        android:paddingLeft="5dp"
        android:singleLine="false"
        android:textColorHint="@android:color/black"
        app:layout_constraintBottom_toTopOf="@+id/email_edittext_register"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/email_edittext_register"
        style="@android:style/TextAppearance.Material.Widget.DropDownHint"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/edittext_rounded"
        android:ems="10"
        android:hint="   Email"
        android:inputType="textEmailAddress"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/username_edittext_register" />

    <EditText
        android:id="@+id/password_edittext_register"
        style="@android:style/TextAppearance.Material.Widget.DropDownHint"
        android:layout_width="0dp"
        android:layout_height="50dp"
        android:layout_marginEnd="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/edittext_rounded"
        android:ems="10"
        android:hint="   Password"
        android:inputType="textPassword"
        android:textColor="@android:color/holo_blue_dark"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/email_edittext_register" />

    <CheckBox
        android:id="@+id/gdpr_checkbox_register"
        android:layout_width="208dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="I acknowledge GDPR"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/password_edittext_register" />

    <Button
        android:id="@+id/button_register"
        android:layout_width="201dp"
        android:layout_height="47dp"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="Register"
        android:background="@drawable/rounded_button"
        app:layout_constraintStart_toStartOf="@+id/gdpr_checkbox_register"
        app:layout_constraintTop_toBottomOf="@+id/gdpr_checkbox_register" />

    <TextView
        android:id="@+id/login_text_register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text="Already have an account ?"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button_register" />
</android.support.constraint.ConstraintLayout>

问题是-在实际设备上,所有颜色均默认设置为主题,具体取决于API版本。

我应该在主布局或任何应用程序文件中进行哪些更改,以确保布局看起来与Android Studio的设计模式完全相同? 如何避免使用默认主题?

0 个答案:

没有答案