Android ConstraintLayout constraintHeight_percent not of screen

时间:2018-04-20 01:00:58

标签: android android-constraintlayout

The XML below says height should be 6% of the height of the entire ConstraintLayout, not the parent's view. This particular ConstraintLayout is about 2.5 screens high in a ScrollView

How can I get the height to be 6% of the screen height?

<TextView
    android:id="@+id/udpate_profile"
    app:layout_constraintTop_toBottomOf="@+id/boardgames"
    android:layout_marginTop="50dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_width="0dp"
    app:layout_constraintHeight_percent="0.06"
    android:layout_height="0dp"
    android:text="@string/update_profile"
    android:tag="update"
    android:gravity="center"
    android:textSize="18sp"
    android:textColor="@color/white_color"
    android:background="@color/orange_color"
    android:lines="1"
    />

Screenshot

1 个答案:

答案 0 :(得分:0)

对于可能面临同样问题的任何其他人,如this answer 中所述,最好的方法是使用 app:layout_constraintDimensionRatio

相关问题