Одним из распространенных подходов является создание пользовательского макета :
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:id="@+id/selector"
android:background="@color/selector_color"
android:layout_width="match_parent"
android:layout_height="5dp"
android:visibility="invisible" /> <!--Mind the case here-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_home" />
</LinearLayout>
. Используйте ClickEvents
для переключения видимости selector
Itне будет меняться от устройства к устройству .Я предлагаю использовать ConstraintLayout
с атрибутом match_constraint
и guidelines
.
Документы для руководящих принципов