2017-11-06 25 views
-1

ConstraintLayoutの高さはwrap_contentです。goneMarginはwrap_content ConstraintLayoutで尊重されていませんか?

子供の身長に応じて、身長が崩壊したり拡張したりすることができるようにしたい。シンプルで一般的には十分でしょうか?

今、私はこのようになりますレイアウトを持っています。 enter image description here
(まず、下部に異常な超大型マージンを無視してくださいあなたが見ることができるように、マージンがちょうど16dpですが、プレビューは非常にレンダリング大きなマージン。)

大きな長方形の可視性がgoneに設定されている場合、私はその可視性がある場合でも、そのgoneMarginTop certainValueに、それはそのマージンを保持します設定した場合、
は、ConstraintLayoutの文書によると、私の問題はありますgone。私のRequest Dateには親の一番下にいくらかのスペースがあります。

ただし、これは期待どおりに機能しません。 enter image description here

は私が何か間違ったことを行っている(これは私の本当のアプリでは、私は完全な依頼日を見ることができる午前再び壊れプレビューです。):Request Dateは、その親の下に貼り?ここに私の完全なコードがあります:

<?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="wrap_content" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:background="@color/colorBasicGrey" 
    android:layout_marginBottom="2dp"> 

    <View 
     android:id="@+id/item_indicator" 
     android:layout_width="8dp" 
     android:layout_height="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:background="@color/white" 
     android:layout_marginTop="24dp" 
     android:layout_marginLeft="24dp"/> 

    <TextView 
     android:id="@+id/group_member_label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/group_member_join_group_request" 
     app:layout_constraintTop_toBottomOf="@id/item_indicator" 
     app:layout_constraintBottom_toTopOf="@id/item_indicator" 
     app:layout_constraintLeft_toRightOf="@id/item_indicator" 
     android:layout_marginLeft="8dp" 
     style="@style/general45"/> 

    <TextView 
     android:id="@+id/group_member_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/general45" 
     android:textAllCaps="true" 
     app:layout_constraintBaseline_toBaselineOf="@id/group_member_label" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginLeft="180dp" 
     tools:text="ABCDEFGHIJK"/> 

    <TextView 
     android:id="@+id/group_request_date_label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/group_member_request_date_label" 
     app:layout_constraintTop_toBottomOf="@id/group_member_label" 
     app:layout_constraintLeft_toLeftOf="@id/group_member_label" 
     android:layout_marginTop="8dp" 
     style="@style/general45"/> 

    <TextView 
     android:id="@+id/group_request_date" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     style="@style/general45" 
     android:textAllCaps="true" 
     app:layout_constraintBaseline_toBaselineOf="@id/group_request_date_label" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginLeft="180dp" 
     tools:text="28/10/2017"/> 

    <LinearLayout 
     android:id="@+id/admin_button_container" 
     android:layout_width="0dp" 
     android:layout_height="48dp" 
     android:layout_marginBottom="16dp" 
     android:layout_marginLeft="24dp" 
     android:layout_marginRight="24dp" 
     android:layout_marginTop="12dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@id/group_request_date_label" 
     app:layout_constraintVertical_bias="0.0" 
     app:layout_goneMarginTop="16dp" 
     app:layout_goneMarginLeft="24dp" 
     app:layout_goneMarginRight="24dp" 
     app:layout_goneMarginBottom="0dp" 
     android:visibility="gone"> 

     <!--To simplify the question, I hided elements inside this LinearLayout--> 

    </LinearLayout> 

</android.support.constraint.ConstraintLayout> 
+1

私はStackoverflowがdownvotingの理由を与える必要があることを望みます。 –

答えて

2

それを実証しました。

goneMarginは、GONEターゲットへのマージンを、それ自体がGONEではなくと示すために使用します。

実際には、goneMargin属性を大きな矩形の代わりにRequest Dateに配置する必要があります。

関連する問題