Android虚拟设备检测到错误的屏幕尺寸?

时间:2019-01-23 14:20:01

标签: android android-studio android-emulator

当我在android编辑器上完全编辑GUI并运行它时。 Android虚拟设备将其重叠在底角。 我正在使用android studio最新版本

Android编辑器

enter image description here

Android虚拟设备(Nexus_5X_API_28)

enter image description here

  <?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="h,640:371"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.046"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:srcCompat="@drawable/header_bg" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="0dp"
        android:layout_height="160dp"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintDimensionRatio="w,35:55"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        app:srcCompat="@drawable/book_cover" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="12dp"
        android:layout_marginEnd="2dp"
        android:layout_marginRight="2dp"
        android:text="Buisness Advise for starting a small buisness"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/imageView2"
        app:layout_constraintTop_toBottomOf="@+id/imageView" />

    <Button
        android:id="@+id/buy"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="48dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:background="@drawable/buy_button"
        android:padding="10dp"
        android:text="5$"
        android:textColor="@android:color/white"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toStartOf="@+id/wishlist"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2" />

    <Button
        android:id="@+id/wishlist"
        android:layout_width="172dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="4dp"
        android:layout_marginLeft="4dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:background="@drawable/buy_button"
        android:padding="10dp"
        android:text="WishList+"
        android:textColor="@android:color/white"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintBaseline_toBaselineOf="@+id/buy"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/buy" />

    <ImageView
        android:id="@+id/rating"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:layout_marginTop="44dp"
        android:background="@drawable/rating"
        app:layout_constraintEnd_toStartOf="@+id/comment"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buy"
        app:srcCompat="@drawable/ic_star"
        tools:ignore="VectorDrawableCompat" />

    <ImageView
        android:id="@+id/comment"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@drawable/comment"
        app:layout_constraintBottom_toBottomOf="@+id/rating"
        app:layout_constraintEnd_toStartOf="@+id/style"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/rating"
        app:layout_constraintTop_toTopOf="@+id/rating"
        app:srcCompat="@drawable/ic_speaker"
        tools:ignore="VectorDrawableCompat" />

    <ImageView
        android:id="@+id/style"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:background="@drawable/style"
        app:layout_constraintBottom_toBottomOf="@+id/comment"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/comment"
        app:layout_constraintTop_toTopOf="@+id/comment"
        app:srcCompat="@drawable/ic_style"
        tools:ignore="VectorDrawableCompat" />

    <TextView
        android:id="@+id/ratinText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="11dp"
        android:text="4.5+"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/rating"
        app:layout_constraintStart_toStartOf="@+id/rating"
        app:layout_constraintTop_toBottomOf="@+id/rating" />

    <TextView
        android:id="@+id/commentText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="11dp"
        android:text="Advices"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/comment"
        app:layout_constraintStart_toStartOf="@+id/comment"
        app:layout_constraintTop_toBottomOf="@+id/comment" />

    <TextView
        android:id="@+id/similarText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="11dp"
        android:text="Similar"
        android:textColor="@android:color/black"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/style"
        app:layout_constraintStart_toStartOf="@+id/style"
        app:layout_constraintTop_toBottomOf="@+id/style" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        android:text="In this video, I am designing an Android App's Book Details/Buy Page UI(User Interface) with ConstraintLayout"
        android:textColor="@android:color/black"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/commentText" />
</android.support.constraint.ConstraintLayout>

当我在android编辑器上完全编辑GUI并运行它时。 Android虚拟设备将其重叠在底角。

如何解决此问题。

1 个答案:

答案 0 :(得分:1)

您可以通过使用ScrollView包装xml布局来处理它,请尝试

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="h,640:371"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.046"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0"
            app:srcCompat="@drawable/ic_launcher_background" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="0dp"
            android:layout_height="160dp"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            app:layout_constraintBottom_toBottomOf="@+id/imageView"
            app:layout_constraintDimensionRatio="w,35:55"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageView"
            app:srcCompat="@drawable/ic_launcher_background" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="12dp"
            android:layout_marginEnd="2dp"
            android:layout_marginRight="2dp"
            android:text="Buisness Advise for starting a small buisness"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/imageView2"
            app:layout_constraintTop_toBottomOf="@+id/imageView" />

        <Button
            android:id="@+id/buy"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="48dp"
            android:layout_marginEnd="16dp"
            android:layout_marginRight="16dp"
            android:background="@drawable/ic_launcher_background"
            android:padding="10dp"
            android:text="5$"
            android:textColor="@android:color/white"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toStartOf="@+id/wishlist"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintHorizontal_chainStyle="packed"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageView2" />

        <Button
            android:id="@+id/wishlist"
            android:layout_width="172dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            android:layout_marginLeft="4dp"
            android:layout_marginEnd="16dp"
            android:layout_marginRight="16dp"
            android:background="@drawable/ic_launcher_background"
            android:padding="10dp"
            android:text="WishList+"
            android:textColor="@android:color/white"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintBaseline_toBaselineOf="@+id/buy"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/buy" />

        <ImageView
            android:id="@+id/rating"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_marginTop="44dp"
            android:background="@drawable/ic_launcher_background"
            app:layout_constraintEnd_toStartOf="@+id/comment"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/buy"
            app:srcCompat="@drawable/ic_launcher_background"
            tools:ignore="VectorDrawableCompat" />

        <ImageView
            android:id="@+id/comment"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:background="@drawable/ic_launcher_background"
            app:layout_constraintBottom_toBottomOf="@+id/rating"
            app:layout_constraintEnd_toStartOf="@+id/style"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/rating"
            app:layout_constraintTop_toTopOf="@+id/rating"
            app:srcCompat="@drawable/ic_launcher_background"
            tools:ignore="VectorDrawableCompat" />

        <ImageView
            android:id="@+id/style"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:background="@drawable/ic_launcher_background"
            app:layout_constraintBottom_toBottomOf="@+id/comment"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/comment"
            app:layout_constraintTop_toTopOf="@+id/comment"
            app:srcCompat="@drawable/ic_launcher_background"
            tools:ignore="VectorDrawableCompat" />

        <TextView
            android:id="@+id/ratinText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="11dp"
            android:text="4.5+"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toEndOf="@+id/rating"
            app:layout_constraintStart_toStartOf="@+id/rating"
            app:layout_constraintTop_toBottomOf="@+id/rating" />

        <TextView
            android:id="@+id/commentText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="11dp"
            android:text="Advices"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toEndOf="@+id/comment"
            app:layout_constraintStart_toStartOf="@+id/comment"
            app:layout_constraintTop_toBottomOf="@+id/comment" />

        <TextView
            android:id="@+id/similarText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="11dp"
            android:text="Similar"
            android:textColor="@android:color/black"
            android:textSize="24sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toEndOf="@+id/style"
            app:layout_constraintStart_toStartOf="@+id/style"
            app:layout_constraintTop_toBottomOf="@+id/style" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginLeft="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginBottom="8dp"
            android:text="In this video, I am designing an Android App's Book Details/Buy Page UI(User Interface) with ConstraintLayout"
            android:textColor="@android:color/black"
            android:textSize="18sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/commentText" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>