2017-07-18 36 views
0

我创建其中包含一个约束布局我怎样才能在Android的约束布局

代码中的两个布局登录表单改变链的高度是这样的:

<?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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#424242" 
    android:orientation="vertical"> 
    <android.support.constraint.Guideline 
     android:id="@+id/login_guideline_start" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:layout_constraintGuide_percent="@dimen/guideline_perc_start" /> 
    <android.support.constraint.Guideline 
     android:id="@+id/login_guideline_end" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     app:layout_constraintGuide_percent="@dimen/guideline_perc_end" /> 
    <android.support.v7.widget.AppCompatImageView 
     android:id="@+id/login_logo" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:scaleType="center" 
     app:layout_constraintBottom_toTopOf="@+id/login_form" 
     app:layout_constraintLeft_toLeftOf="@id/login_guideline_start" 
     app:layout_constraintRight_toLeftOf="@id/login_guideline_end" 
     app:layout_constraintTop_toTopOf="parent" 
     app:srcCompat="@drawable/rooll" /> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/login_form" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="@id/login_guideline_start" 
     app:layout_constraintRight_toLeftOf="@id/login_guideline_end" 
     app:layout_constraintTop_toBottomOf="@id/login_logo"> 

     --the controls for the login form go here-- 

    </android.support.constraint.ConstraintLayout> 

</android.support.constraint.ConstraintLayout> 

准则是用来使窗体显示在平板电脑上的横向视图中,并在纵向视图填充手机上的屏幕

我的问题是,因为我创建了徽标和窗体之间的链,父徽标之间的链高度和形式总是一样的。

有没有办法改变链条的高度?例如,我可以使父母和商标之间的约束高度为0dp,标识和形式之间的链条高度是形式和父母之间的高度的一半吗?提前任何帮助

感谢你能提供

回答

0

看看这个tutorial。您可能需要关注处理连锁权重的this part

加权:当链是通过设置一个或多个视图,以“满足约束”(0dp)设置为传播或传播里面,您可以填写剩余的空间。默认情况下,空间均匀分布在设置为“匹配约束”的每个视图之间,但您可以使用layout_constraintHorizo​​ntal_weight和layout_constraintVertical_weight属性为每个视图指定一个重要权重。如果您熟悉线性布局中的layout_weight,则其工作方式相同。所以重量值最高的视图获得最多的空间;具有相同重量的视图获得相同的空间量。