2017-09-14 11 views
2

に制約を追加私のxmlをご覧ください: はConstraintLayout

<android.support.constraint.ConstraintLayout 
    android:id="@+id/constraintLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?attr/actionBarSize"> 

    <RelativeLayout 
     android:id="@+id/layout_info" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimaryDark" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="parent"/> 

    <include 
     layout="@layout/page" 
     android:layout_width="match_parent" 
     android:layout_height="0dp"/> 

</android.support.constraint.ConstraintLayout> 

は私が<include>に制約を追加することはできませんよ。 app名前空間は機能しません(RelativeLayoutで機能します)。自動入力は制約属性を表示しません。私は、含まれているレイアウトの高さを残りのスペースをConstraintLayoutにしたいが、どのように制約なしにそれを行うのですか?助けてください。

答えて

2

のAndroid Studioは、タグを含んでconstraintLayoutパラメータを自動補完しませんが、彼らは限り、あなたはサイズが含まれていることを与えるとして、それに影響を持っています。

この

<android.support.constraint.ConstraintLayout 
    android:id="@+id/constraintLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?attr/actionBarSize"> 

    <RelativeLayout 
     android:id="@+id/layout_info" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:background="@color/colorPrimaryDark" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintTop_toTopOf="parent"/> 

    <include 
     layout="@layout/page" 
     android:layout_width="0dp" 
     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> 
を試してみてください
0

はこれを試してみてください。

<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:id="@+id/constraintLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?attr/actionBarSize"> 

<RelativeLayout 
    android:id="@+id/layout_info" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:background="@color/colorPrimaryDark" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toStartOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    /> 

<include 
    layout="@layout/page" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 

</android.support.constraint.ConstraintLayout> 
関連する問題