У меня линейная раскладка с weightSum=3
и orientation=horizontal
. В линейном макете у меня есть 3 дочерних линейных макета, каждый из которых имеет layout_weight=1
, значок и текстовое представление, как показано ниже:
Проблема, с которой я сталкиваюсь, заключается в том, что мне не нужно редактировать каждый из линейные макеты в нескольких местах, есть ли способ заключить это? где я могу просто установить значок и текстовое представление и инкапсулированный отступ, масштабный тип изображения
![enter image description here](https://i.stack.imgur.com/L1hXS.png)
Вот мой xml, я Показываю первые два для краткости:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
android:layout_marginLeft="@dimen/paddingLarge"
android:layout_marginRight="@dimen/paddingLarge"
android:layout_marginTop="@dimen/paddingLarge">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="@dimen/paddingSmall">
<ImageView
android:layout_width="@dimen/bottomsheet_option_icon"
android:layout_height="@dimen/bottomsheet_option_icon"
android:src="@drawable/priority_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:text="Priority"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
android:padding="@dimen/paddingSmall"
>
<ImageView
android:layout_width="@dimen/bottomsheet_option_icon"
android:layout_height="@dimen/bottomsheet_option_icon"
android:scaleType="centerCrop"
android:src="@drawable/date_time_icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Priority"
android:textColor="@android:color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="@dimen/bottomsheet_option_icon"
android:layout_height="@dimen/bottomsheet_option_icon"
android:scaleType="centerCrop"
android:src="@drawable/notification_icon"/>
<TextView
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Priority"/>
</LinearLayout>
</LinearLayout>