Please take a look at my xml:
<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>
I'm not able to add constraint to the <include>
. The app
namespace doesn't work (it works for the RelativeLayout
) and auto fill doesn't show the constraint attributes. I want the included layout's height to be the remaining space in the ConstraintLayout
, but how do I do it without constraints! Please help.
The TextView above has three types of handles: Resize handle - It's present on the four corners and is used to resize the view, but keeping its constraints intact. Side handle - It's the circular handle present on the centre of each side. It's used to set the top, left, bottom and right constraints of the view.
You can't use relative layout directly inside constraint layout. Intention of ConstraintLayout is to optimize and flatten the view hierarchy of your layouts by applying some rules to each view to avoid nesting.
If you have the choice start with ConstraintLayout, but if you already have your app in RelativeLayout, stay with it. That's all I have been following. RelativeLayout is very limited in functionality and many complex layouts can't be made using it, especially when ratios are involved.
More complex layout but results are the same, flat Constraint Layout is slower than nested Linear Layout.
<include layout="@layout/layout_no_friends_avalable"
android:id="@+id/inc_no_friend"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_main"
/>
When adding constraints in <include>
tag we must use android:layout_width
and android:layout_height
both attributes.
Try this
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With