我試圖用
在工具列內的ImageView中制作波紋效果。android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
但是當我運行這個應用程式時,輸出看起來像?attr/selectableItemBackground。然后我試圖將Toolbar改為RelativeLayout。它是有效的,但我需要使用Toolbar而不是RelativeLayout。
我也在嘗試使用android:background="?attr/selectableItemBackgroundBorderless"。但如果我使用android:background,就沒有波紋效果。下面是我的代碼:
<?xml version="1.0" encoding="utf-8"? >
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"/span>
xmlns:app="http://schemas.android.com/apk/res-auto"。
xmlns:tools="http://schemas.android.com/tools"。
android:layout_width="match_parent"。
android:layout_height="match_parent"。
android:background="@color/colorGrey"
tools:context=".User.BottomNavigationView.Student.StudentDetailActivity"/span>>
<com.google.android.material.appbar.AppBarLayout。
android:id="@ id/student_detail_app_bar_layout"
android:layout_width="match_parent"。
android:layout_height="300dp"。
android:fitsSystemWindows="true"。
android:theme="@style/ActionBarTextColor"/span>>
<com.google.android.material.appbar.CollapsingToolbarLayout。
android:id="@ id/student_detail_collapsing_toolbar"/span>
android:layout_width="match_parent"。
android:layout_height="match_parent"。
android:fitsSystemWindows="true"。
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="roll|exitUntilCollapsed"。
app:title="Detail Siswa"/span>>
<ImageView。
android:id="@ id/student_detail_profile_picture_image_view"
android:layout_width="match_parent"。
android:layout_height="match_parent"。
android:scaleType="centerCrop"。
android:src="@drawable/img1"。
app:layout_collapseMode="parallax"/span> />
<androidx.appcompat.widget.Toolbar。
android:id="@ id/student_detail_toolbar"/span>
android:layout_width="match_parent"。
android:layout_height="? android:actionBarSize"
app:layout_collapseMode="pin"/span>>
<ImageView。
android:id="@ id/student_detail_back_button_image_view"
android:layout_width="30dp"/span>
android:layout_height="30dp"/span>
android:layout_centerVertical="true"。
android:layout_marginEnd="32dp"/span>
android:clickable="true"。
android:foreground="?attr/selectableItemBackgroundBorderless"。
android:padding="3dp"。
android:src="@drawable/general_back_button"
app:tint="@color/colorPrimaryIcon" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView。
android:layout_width="match_parent"
android:layout_height="match_parent"。
android:background="@color/colorGrey"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我想在工具條內的ImageView中使用?attr/selectableItemBackgroundBorderless或circular ripple effect。我怎樣才能做到這一點呢?
uj5u.com熱心網友回復:
添加focusable true就可以了
。android:focusable="true"
下面我加入了可點擊和可關注的代碼
android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/313086.html
標籤:
