Ich versuche, Klickeffekt auf Bildansicht in benutzerdefinierten Layout innerhalb der Symbolleiste platziert geben. So habe ich es wie folgt umgesetzt:Android Toolbar benutzerdefinierte Layout anklickbare Symbol mit Selektor animierten Hintergrund
diese in Symbolleiste enthalten ist:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/img_tool_back"
style="@style/SelectorLayout"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back_grey_600_24dp"/>
</LinearLayout>
.
. //Other action buttons
.
</Linearlayout>
Selector Layout-Stil hat:
<style name="SelectorLayout">
<item name="android:layout_width">?attr/actionBarSize</item>
<item name="android:layout_height">?attr/actionBarSize</item>
<item name="android:gravity">center</item>
<item name="android:background">@drawable/selector_action</item>
</style>
und animierte Aktion Selektor ist:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:drawable="@color/colorGray" android:state_selected="true"/>
<item android:drawable="@color/colorGray" android:state_pressed="true"/>
<item android:drawable="@color/colorGray" android:state_focused="true"/>
<item android:drawable="@android:color/transparent"/>
</selector>
Ich habe mich gefragt, ob es möglich ist, denselben Effekt mit nur einer einzigen Bildansicht zu erzielen? anstatt Bildansicht im linearen Layout zu verwenden?