I have a custom view containing two rows with 4 other custom views each and borders around every one of those 8 custom views.
In the xml I'm using ConstraintLayout
and I have two invisible views for the first row and the second row which help me with making the views having the same width
-s and height
-s.
Design is working great but what annoys me is that the rendering is too slow. I tried removing the constraints
of the views and it appears to be working way faster without them.
My questions is: is there a way to improve the performance of this view or is that the right way of doing this.
Here's the xml
I'm using:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/first_row"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="4:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/all_background_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_all"
android:visibility="invisible"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintEnd_toStartOf="@id/stay_filter_view"
app:layout_constraintStart_toStartOf="@id/first_row"
app:layout_constraintTop_toTopOf="@id/first_row"
app:layout_constraintBottom_toBottomOf="@id/first_row"/>
<com.my.app.presentation.component.FilterObjectTypeIconlessView
android:id="@+id/all_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_all"
app:layout_constraintStart_toStartOf="@id/all_background_filter_view"
app:layout_constraintEnd_toEndOf="@id/all_background_filter_view"
app:layout_constraintTop_toTopOf="@id/all_background_filter_view"
app:layout_constraintBottom_toBottomOf="@id/all_background_filter_view"/>
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/stay_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toStartOf="@id/restaurants_filter_view"
app:layout_constraintStart_toEndOf="@id/all_background_filter_view"
app:layout_constraintTop_toTopOf="@id/first_row"
app:layout_constraintBottom_toBottomOf="@id/first_row"
custom:src="@drawable/icon__accomodation__x3"
custom:text="@string/filter_stay" />
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/restaurants_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_restaurants"
custom:src="@drawable/icon__restaurant__x3"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/stay_filter_view"
app:layout_constraintEnd_toStartOf="@id/shops_filter_view"
app:layout_constraintTop_toTopOf="@id/first_row"
app:layout_constraintBottom_toBottomOf="@id/first_row" />
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/shops_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_shops"
custom:src="@drawable/icon__shop__x3"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/restaurants_filter_view"
app:layout_constraintTop_toTopOf="@id/first_row"
app:layout_constraintBottom_toBottomOf="@id/first_row"
app:layout_constraintEnd_toEndOf="@id/first_row"/>
<android.support.constraint.ConstraintLayout
android:id="@+id/second_row"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="4:1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/first_row" />
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/sights_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_sights"
custom:src="@drawable/icon__sights__x3"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toStartOf="@id/second_row"
app:layout_constraintEnd_toStartOf="@id/sports_filter_view"
app:layout_constraintTop_toTopOf="@id/second_row"
app:layout_constraintBottom_toBottomOf="@id/second_row"
/>
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/sports_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_sports"
custom:src="@drawable/icon__sport__x3"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/sights_filter_view"
app:layout_constraintEnd_toStartOf="@id/educational_filter_view"
app:layout_constraintTop_toTopOf="@id/second_row"
app:layout_constraintBottom_toBottomOf="@id/second_row"/>
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/educational_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_educational"
custom:src="@drawable/icon__study__x3"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/sports_filter_view"
app:layout_constraintEnd_toStartOf="@id/public_filter_view"
app:layout_constraintTop_toTopOf="@id/second_row"
app:layout_constraintBottom_toBottomOf="@id/second_row"/>
<com.my.app.presentation.component.FilterObjectTypeWithImageView
android:id="@+id/public_filter_view"
android:layout_width="0dp"
android:layout_height="0dp"
custom:text="@string/filter_public"
custom:src="@drawable/icon__public__x3"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="@id/second_row"
app:layout_constraintTop_toTopOf="@id/second_row"
app:layout_constraintStart_toEndOf="@id/educational_filter_view"
app:layout_constraintBottom_toBottomOf="@id/second_row"/>
<View
android:id="@+id/all_filter_top_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/all_filter_view"
app:layout_constraintEnd_toStartOf="@id/stay_filter_view"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/all_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/all_filter_view"
app:layout_constraintEnd_toStartOf="@id/stay_filter_view"
app:layout_constraintTop_toBottomOf="@id/all_filter_view"/>
<View
android:id="@+id/stay_filter_top_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/stay_filter_view"
app:layout_constraintEnd_toStartOf="@id/restaurants_filter_view"
app:layout_constraintTop_toTopOf="@id/stay_filter_view"/>
<View
android:id="@+id/stay_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/stay_filter_view"
app:layout_constraintEnd_toStartOf="@id/restaurants_filter_view"
app:layout_constraintTop_toBottomOf="@id/stay_filter_view"/>
<View
android:id="@+id/restaurants_filter_top_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/restaurants_filter_view"
app:layout_constraintEnd_toStartOf="@id/shops_filter_view"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/restaurants_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/restaurants_filter_view"
app:layout_constraintEnd_toStartOf="@id/shops_filter_view"
app:layout_constraintTop_toBottomOf="@id/restaurants_filter_view"/>
<View
android:id="@+id/shops_filter_top_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/shops_filter_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/shops_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/shops_filter_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/shops_filter_view"/>
<View
android:id="@+id/sights_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/sights_filter_view"
app:layout_constraintEnd_toStartOf="@id/sports_filter_view"
app:layout_constraintBottom_toBottomOf="@id/sights_filter_view"/>
<View
android:id="@+id/sports_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/sports_filter_view"
app:layout_constraintEnd_toStartOf="@id/educational_filter_view"
app:layout_constraintBottom_toBottomOf="@id/sports_filter_view"/>
<View
android:id="@+id/educational_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/educational_filter_view"
app:layout_constraintEnd_toStartOf="@id/public_filter_view"
app:layout_constraintBottom_toBottomOf="@id/educational_filter_view"/>
<View
android:id="@+id/public_filter_bottom_border"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toStartOf="@id/public_filter_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/public_filter_view"/>
<View
android:id="@+id/all_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/all_filter_view"
app:layout_constraintBottom_toBottomOf="@id/all_filter_view"
app:layout_constraintStart_toStartOf="@id/all_filter_view"/>
<View
android:id="@+id/sights_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/sights_filter_view"
app:layout_constraintBottom_toBottomOf="@id/sights_filter_view"
app:layout_constraintStart_toStartOf="@id/sights_filter_view"/>
<View
android:id="@+id/stay_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/stay_filter_view"
app:layout_constraintBottom_toTopOf="@id/sports_filter_view"
app:layout_constraintStart_toStartOf="@id/stay_filter_view"/>
<View
android:id="@+id/sports_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/sports_filter_view"
app:layout_constraintBottom_toBottomOf="@id/sports_filter_view"
app:layout_constraintStart_toStartOf="@id/sports_filter_view"/>
<View
android:id="@+id/restaurants_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/restaurants_filter_view"
app:layout_constraintBottom_toTopOf="@id/educational_filter_view"
app:layout_constraintStart_toStartOf="@id/restaurants_filter_view"/>
<View
android:id="@+id/educational_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/educational_filter_view"
app:layout_constraintBottom_toBottomOf="@id/educational_filter_view"
app:layout_constraintStart_toStartOf="@id/educational_filter_view"/>
<View
android:id="@+id/shops_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/shops_filter_view"
app:layout_constraintBottom_toTopOf="@id/public_filter_view"
app:layout_constraintStart_toStartOf="@id/shops_filter_view"/>
<View
android:id="@+id/public_filter_left_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/public_filter_view"
app:layout_constraintBottom_toBottomOf="@id/public_filter_view"
app:layout_constraintStart_toStartOf="@id/public_filter_view"/>
<View
android:id="@+id/shops_filter_right_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/shops_filter_view"
app:layout_constraintBottom_toBottomOf="@id/shops_filter_view"
app:layout_constraintEnd_toEndOf="@id/shops_filter_view"/>
<View
android:id="@+id/public_filter_right_border"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintTop_toTopOf="@id/public_filter_view"
app:layout_constraintBottom_toBottomOf="@id/public_filter_view"
app:layout_constraintEnd_toEndOf="@id/public_filter_view"/>
<View
android:id="@+id/first_border_center_pixel"
android:layout_width="1dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toEndOf="@id/all_filter_bottom_border"
app:layout_constraintBottom_toBottomOf="@id/all_filter_bottom_border" />
<View
android:id="@+id/second_border_center_pixel"
android:layout_width="1dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toEndOf="@id/stay_filter_bottom_border"
app:layout_constraintBottom_toBottomOf="@id/stay_filter_bottom_border" />
<View
android:id="@+id/third_border_center_pixel"
android:layout_width="1dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintStart_toEndOf="@id/restaurants_filter_bottom_border"
app:layout_constraintBottom_toBottomOf="@id/restaurants_filter_bottom_border" />
<View
android:id="@+id/fourth_border_center_pixel"
android:layout_width="1dp"
android:layout_height="1dp"
android:background="@color/filterUnactivatedColor"
app:layout_constraintEnd_toEndOf="@id/shops_filter_bottom_border"
app:layout_constraintBottom_toBottomOf="@id/shops_filter_bottom_border" />
</android.support.constraint.ConstraintLayout>