在我的预览中一切看起来不错,但是当我在模拟器中打开应用程序时,布局与长度或宽度的父级不匹配。一切都在它应该在布局中的位置,它不能与屏幕整体拉伸。这发生在应用程序的每个布局中(我正在使用片段)。为了更好地解释继承人PIX:Android Studio布局。将不匹配父母
**我有什么
这里是XML。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/hlineand"/>
<TextView
android:id="@+id/userTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="User"
android:textAlignment="center"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textColor="@android:color/darker_gray"
android:textSize="30dp"/>
<TextView
android:id="@+id/updateTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:text="----"
android:textAlignment="center"/>
<EditText
android:id="@+id/emailEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:ems="10"
android:hint="e-mail"
android:inputType="textEmailAddress"
android:layout_below="@+id/userTextView"
android:layout_centerHorizontal="true"/>
<EditText
android:id="@+id/passwordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/emailEditText"
android:layout_below="@+id/emailEditText"
android:layout_marginTop="24dp"
android:ems="10"
android:hint="password"
android:inputType="textPassword"/>
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/passwordEditText"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Login"/>
</RelativeLayout>
这是我的内容main.xml。就像第一位提到的评论者那样,它就在那里。它工作得很好,当我把匹配父&匹配的父母,但不是它的调整大小像宽度344px &高度590px。任何方式,我可以保持作为配对父母?
<?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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.a2.reach.MainActivity"
tools:showIn="@layout/app_bar_main">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="344dp"
android:layout_height="495dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
你需要发表您的主要布局,我的意思是布局包含片段容器,请参阅容器ISN” t设置为match_parent –
@ Du.Fantasy我将我的主要内容添加进去了,你已经准备好了要去的地方。 –
你是什么意思,但不是它调整大小像宽度344px和高度590px“,我不清楚你的目的 –