Android Xml 布局问题导致 textView 下移

问题描述 投票:0回答:1

我不知道为什么布局设计在模拟器上看起来是正确的。 请检查屏幕截图和代码。几乎就像有东西在其他东西上面一样,导致工具栏和文本视图向下移动一点。我尝试一遍又一遍地更改或删除这些元素,但没有运气。任何帮助将不胜感激

谢谢你。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:background="@color/BackGround"
tools:context=".ReportError">

<include
    android:id="@+id/include"
    layout="@layout/toolbar"
    android:layout_width="match_parent"
    android:layout_height="55dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.textview.MaterialTextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:elevation="5dp"
    android:padding="15dp"
    android:text="@string/report"
    android:textAlignment="center"
    android:textColor="@color/white"
    android:textSize="25sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/textViewImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="64dp"
    android:fontFamily="sans-serif-black"
    android:text="@string/Choose_image"
    android:textColor="@color/black"
    android:textSize="18sp"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintHorizontal_bias="0.515"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toBottomOf="@+id/include" />

<ImageView
    android:id="@+id/image_view"
    android:layout_width="0dp"
    android:layout_height="130dp"
    android:layout_marginTop="48dp"
    android:alpha="3.0"
    android:background="@drawable/circle"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toBottomOf="@+id/textViewImage" />

<TextView
    android:id="@+id/textViewE"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="24dp"
    android:fontFamily="sans-serif-black"
    android:text="@string/enter_a_detailed_description_of_the_problem"
    android:textColor="@color/black"
    android:textSize="18sp"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintHorizontal_bias="0.539"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toBottomOf="@+id/image_view" />

<EditText
    android:id="@+id/txtdata"
    android:layout_width="0dp"
    android:layout_height="150dp"
    android:layout_gravity="center"
    android:layout_marginTop="36dp"
    android:alpha="3.0"
    android:background="@drawable/circle"
    android:ems="10"
    android:gravity="start|top"
    android:inputType="textMultiLine"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toBottomOf="@+id/textViewE" />

<Button
    android:id="@+id/btnbrowse"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="36dp"
    android:layout_marginTop="32dp"
    android:text="@string/browse"
    android:textColor="@color/black"
    app:layout_constraintBottom_toTopOf="@+id/guideline22"
    app:layout_constraintEnd_toStartOf="@+id/guideline23"
    app:layout_constraintHorizontal_bias="0.377"
    app:layout_constraintStart_toStartOf="@+id/guideline20"
    app:layout_constraintTop_toBottomOf="@+id/txtdata"
    app:layout_constraintVertical_bias="0.0" />

<Button
    android:id="@+id/btnupload"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="32dp"
    android:layout_marginEnd="36dp"
    android:text="@string/upload"
    android:textColor="@color/black"
    app:layout_constraintBottom_toTopOf="@+id/guideline22"
    app:layout_constraintEnd_toStartOf="@+id/guideline21"
    app:layout_constraintHorizontal_bias="0.765"
    app:layout_constraintStart_toStartOf="@+id/guideline23"
    app:layout_constraintTop_toBottomOf="@+id/txtdata"
    app:layout_constraintVertical_bias="0.0" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline20"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.05" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline21"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.93" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline22"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="0.98" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline23"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.50" />

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="88dp"
    android:visibility="invisible"
    app:layout_constraintEnd_toEndOf="@+id/txtdata"
    app:layout_constraintHorizontal_bias="0.484"
    app:layout_constraintStart_toStartOf="@+id/txtdata"
    app:layout_constraintTop_toBottomOf="@+id/textViewE" />

    </androidx.constraintlayout.widget.ConstraintLayout>
android xml layout responsive-design android-toolbar
1个回答
0
投票

考虑将

android:fitsSystemWindows="true"
添加到根布局。或到你的根
theme

<androidx.constraintlayout.widget.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"
android:fitsSystemWindows="true"
android:background="@color/BackGround"
tools:context=".ReportError">

适合系统Windows

它设置视图的填充以确保内容不会重叠 系统窗口。

© www.soinside.com 2019 - 2024. All rights reserved.