I have a huge layout file with one flat constraint layout within.
I have android.support.constraint.Group
elements that are identical. I want to move these to a separate file and then include them like <include layout="@layout/selection_group"/>
The problem I'm facing is that the group that I have in the file selection_group.xml
is not previewed correctly in Android studio. Is there a way to make Android Studio preview this directly in the file or include them in a different way?
selection_group.xml
<layout 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.support.constraint.Group
android:id="@+id/top_bar_config_one_background_group"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/top_bar_background_with_border_fx"
android:clickable="true"
app:constraint_referenced_ids="top_bar_config_one,top_bar_tooth_one"
app:layout_constraintBottom_toBottomOf="@+id/top_bar_container_background"
app:layout_constraintLeft_toLeftOf="@+id/top_bar_container_background"
app:layout_constraintRight_toLeftOf="@+id/top_bar_config_two"
app:layout_constraintTop_toTopOf="@+id/top_bar_container_background" />
<ImageView
android:id="@+id/top_bar_config_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:scaleType="center"
android:src="@drawable/ic_height_over_sea_100x26"
app:layout_constraintBottom_toTopOf="@+id/top_bar_tooth_one"
app:layout_constraintLeft_toLeftOf="@+id/top_bar_container_background"
app:layout_constraintRight_toLeftOf="@+id/top_bar_config_two"
app:layout_constraintTop_toTopOf="@+id/top_bar_config_one_background_group" />
<ImageView
android:id="@+id/top_bar_tooth_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="@drawable/ic_tooth_auto_40x40"
app:layout_constraintBottom_toBottomOf="@+id/top_bar_config_one_background_group"
app:layout_constraintLeft_toLeftOf="@+id/top_bar_container_background"
app:layout_constraintRight_toLeftOf="@+id/top_bar_config_two" />
<?xml version="1.0" encoding="utf-8"?>
</layout>
I don't want to nest multiple constraint layouts together. I think the root <layout>
view in selection_group.xml
is optimized and does not affect the performance? My goal is to reduce redundant code and not affect performance