sto*_*fln 9 android android-button android-view material-design rippledrawable
我正在使用selectableItemBackgroundBorderless添加波纹ImageView.我的预期行为是圆形波纹,扩大视图大小.不幸的是,波纹被视角限制.如何解决这个问题?
默认状态:
压制状态:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nav_instruction_container"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/nav_gradient_bg"
android:padding="20dp">
<ImageView
android:id="@+id/nav_sign"
android:layout_width="wrap_content"
android:layout_height="46dp"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:adjustViewBounds="true"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/nav_sign"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="bold"
android:maxLines="2"
tools:text="A644 Shudehill asdfkjasdf asdfasdf asdfsss"
android:ellipsize="marquee"
/>
<TextView
android:id="@+id/subTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_toRightOf="@+id/nav_sign"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:textColor="@color/white"
android:textSize="17sp"
tools:text="via Church St"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
app:srcCompat="@drawable/ic_nav_queue_sheet_icon_light"
android:id="@+id/nav_queue"
android:scaleType="centerInside"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:adjustViewBounds="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如果你有一个可点击的ImageView,那么很可能它应该是一个ImageButton.
定义如下ImageButton:
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/ic_navigation_black_24dp" />
Run Code Online (Sandbox Code Playgroud)
然后你会得到以下输出:

如果你想要更大的涟漪效果,你必须改变视图的大小:而不是wrap_content制作它,比方说,100dp:
| 归档时间: |
|
| 查看次数: |
2036 次 |
| 最近记录: |