我试图在我的代码中实现ContstraintLayout
,但问题是为什么在模拟器和IDE上运行它时会有不同? 的信息,我把ConstraintLayout
在LinearLayout
垂直。 和这里我的XML代码:模拟器和IDE之间的linearLayout不同预览中的Constraintlayout?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main"
tools:context="navotera.syasep.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="170dp"
>
<RelativeLayout
android:id="@+id/topBorder"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@android:color/holo_red_light">
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:scaleType="fitCenter"
android:foregroundGravity="right"
android:src="@mipmap/profile"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.99"
android:id="@+id/imageView3"
app:layout_constraintVertical_bias="0.25"
android:paddingLeft="270dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:paddingLeft="18dp"
android:paddingTop="10dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:textSize="@dimen/text_big"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nama"
android:text="Hendra" />
<TextView
android:textSize="@dimen/text_big"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nim"
android:text="nim" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="right">
<TextView
android:textSize="@dimen/text_bigger"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/semester"
android:text="7"
android:layout_weight="1"
android:layout_marginEnd="184dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="184dp"
app:layout_constraintTop_toBottomOf="@+id/tsemester" />
<TextView
android:text="IPK"
android:textSize="@dimen/text_small"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:id="@+id/tipk"
android:textColor="@color/colorAccent"
android:layout_weight="1"
tools:layout_editor_absoluteY="28dp"
app:layout_constraintRight_toLeftOf="@+id/tsemester"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
app:layout_constraintLeft_toLeftOf="@+id/ipk" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ipk"
android:text="3.99"
android:textSize="@dimen/text_bigger"
android:layout_weight="1"
tools:layout_editor_absoluteY="49dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
app:layout_constraintRight_toLeftOf="@+id/semester"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintHorizontal_bias="0.14" />
<TextView
android:text="Semester"
android:textSize="@dimen/text_small"
android:layout_width="94dp"
android:layout_height="wrap_content"
android:id="@+id/tsemester"
android:textColor="@color/colorAccent"
android:layout_weight="1"
tools:layout_editor_absoluteY="28dp"
tools:layout_editor_absoluteX="156dp" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</RelativeLayout>
<android.support.constraint.ConstraintLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.constraint.ConstraintLayout>
<TextView
android:text="Jadwal/Kehadiran"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="13dp"
android:id="@+id/tkehadiran"
android:textSize="@dimen/text_medium" />
</LinearLayout>
</RelativeLayout>
感谢您的任何建议。
您的LinearLayout不具有方向属性设置 – Nilabja