如何在ConstraintLayout

时间:2019-07-09 12:26:23

标签: android android-constraintlayout

我有一个使用ConstraintLayout构建的登录xml。删除登录编辑文本时,布局顶部出现空白。我尝试将其更改为``垂直偏移'',但它没有变化。将每个对象移到guidline1,但没有任何变化。这是屏幕的外观。 Screen

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/loginbgs"
    tools:context=".login">



    <android.support.constraint.Guideline
        android:id="@+id/guidelineTop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.2"/>
    <android.support.constraint.Guideline
        android:id="@+id/guidelineLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.0"/>
    <android.support.constraint.Guideline
        android:id="@+id/guidelineRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="1.0"/>
    <android.support.constraint.Guideline
        android:id="@+id/guidelineBottom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.7"/>



    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="-480dp"
            android:layout_marginBottom="230dp"
            android:layout_marginTop="190dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentBottom="true"
            android:src="@drawable/cubuk" />


        <ImageView
            android:id="@+id/cubuk2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="-380dp"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="240dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentBottom="true"
            android:src="@drawable/cubuk2" />


        <ImageView
            android:id="@+id/cubuk3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="-690dp"
            android:layout_marginBottom="20dp"
            android:layout_marginTop="240dp"
            android:layout_alignParentTop="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentBottom="true"
            android:src="@drawable/cubuk3" />



    </RelativeLayout>

    <android.support.constraint.ConstraintLayout
        android:id="@+id/consraintLayoutLoginView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toTopOf="@+id/guidelineBottom"
        app:layout_constraintEnd_toStartOf="@+id/guidelineRight"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="@+id/guidelineLeft"
        app:layout_constraintTop_toTopOf="@+id/guidelineTop"
        app:layout_constraintVertical_bias="1.0">


        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.0" />

        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.2" />

        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.4" />

        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.65" />

        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView45"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.90" />

        <android.support.constraint.Guideline
            android:id="@+id/guidelineLoginView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_percent="0.5" />




        <TextView
            android:id="@+id/baslatext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20sp"
            android:layout_marginTop="13sp"
            android:text="  Hemen Başla  "
            android:textStyle="bold"
            android:textSize="@dimen/_18sdp"
            android:textColor="@android:color/white"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.500"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView2"/>

        <ImageView
            android:layout_width="0dp"
            android:layout_height="2dp"
            android:background="@android:color/white"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView3"
            app:layout_constraintEnd_toStartOf="@id/baslatext"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView2"/>


        <ImageView
            android:layout_width="0dp"
            android:layout_height="2dp"
            android:background="@android:color/white"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView3"
            app:layout_constraintStart_toEndOf="@id/baslatext"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView2"/>


        <View
            android:id="@+id/button10"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/googlebtn"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView4"
            app:layout_constraintEnd_toEndOf="@id/guidelineLoginView5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView3" />


        <View
            android:id="@+id/dogrular"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/facesbg"
            android:text="Login"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView4"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@id/guidelineLoginView5"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView3" />



        <View
            android:id="@+id/emailgir"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/emailbtn"
            app:layout_constraintBottom_toTopOf="@+id/guidelineLoginView45"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.498"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/guidelineLoginView4"
            app:layout_constraintVertical_bias="0.5" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20sp"
            android:layout_marginTop="13sp"
            android:text="Google"
            android:textSize="@dimen/_18sdp"
            android:textColor="@android:color/white"
            app:layout_constraintBottom_toBottomOf="@+id/button10"
            app:layout_constraintEnd_toEndOf="@id/button10"
            app:layout_constraintHorizontal_bias="0.385"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/button10" />

        <ImageView
            android:layout_width="@dimen/_30sdp"
            android:layout_height="@dimen/_30sdp"
            android:layout_marginBottom="@dimen/_15sdp"
            android:layout_marginTop="@dimen/_14sdp"
            app:layout_constraintBottom_toBottomOf="@+id/button10"
            app:layout_constraintEnd_toEndOf="@id/button10"
            app:layout_constraintHorizontal_bias="0.890"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/button10"
            app:layout_constraintVertical_bias="0.545"
            app:srcCompat="@drawable/google_circle512" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20sp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="13sp"
            android:text="Facebook"
            android:textColor="@android:color/white"
            android:textSize="@dimen/_18sdp"
            app:layout_constraintBottom_toBottomOf="@+id/dogrular"
            app:layout_constraintEnd_toEndOf="@id/dogrular"
            app:layout_constraintHorizontal_bias="0.09"
            app:layout_constraintStart_toStartOf="@+id/dogrular"
            app:layout_constraintTop_toTopOf="@+id/dogrular" />

        <ImageView
            android:layout_width="@dimen/_30sdp"
            android:layout_height="@dimen/_30sdp"
            android:layout_marginBottom="@dimen/_15sdp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="@dimen/_14sdp"
            app:layout_constraintBottom_toBottomOf="@+id/dogrular"
            app:layout_constraintEnd_toEndOf="@id/dogrular"
            app:layout_constraintHorizontal_bias="0.890"
            app:layout_constraintStart_toStartOf="@+id/dogrular"
            app:layout_constraintTop_toTopOf="@+id/dogrular"
            app:layout_constraintVertical_bias="0.545"
            app:srcCompat="@drawable/facebook_circle" />


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20sp"
            android:layout_marginTop="13sp"
            android:text="E-posta"
            android:textColor="@android:color/white"
            android:textSize="@dimen/_18sdp"
            app:layout_constraintBottom_toBottomOf="@+id/emailgir"
            app:layout_constraintEnd_toEndOf="@id/emailgir"
            app:layout_constraintHorizontal_bias="0.500"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="@+id/emailgir" />


        <ImageView
            android:layout_width="@dimen/_30sdp"
            android:layout_height="@dimen/_30sdp"
            android:layout_marginBottom="@dimen/_15sdp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="@dimen/_14sdp"
            app:layout_constraintBottom_toBottomOf="@+id/emailgir"
            app:layout_constraintEnd_toEndOf="@id/emailgir"
            app:layout_constraintHorizontal_bias="0.890"
            app:layout_constraintStart_toStartOf="@+id/emailgir"
            app:layout_constraintTop_toTopOf="@+id/emailgir"
            app:layout_constraintVertical_bias="0.545"
            app:srcCompat="@drawable/email" />


    </android.support.constraint.ConstraintLayout>


</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案