У меня есть огромный файл макета с одним плоским макетом ограничения внутри.
У меня есть android.support.constraint.Group
идентичные элементы. Я хочу переместить их в отдельный файл и затем включить их, например <include layout="@layout/selection_group"/>
Проблема, с которой я сталкиваюсь, заключается в том, что группа, находящаяся в файле selection_group.xml
, не отображается правильно в Android студия. Есть ли способ сделать Android Studio предпросмотр этого непосредственно в файле или включить их другим способом?
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>
Я не хочу вложите несколько макетов ограничений вместе. Я думаю, что root <layout>
представление в selection_group.xml
оптимизировано и не влияет на производительность? Моя цель - сократить избыточный код и не влиять на производительность