填充可以减少ImageView中的图标大小
问题描述:
我想让我的图标产生连锁反应。但是,当我增加填充它减少图标的大小 当填充是5DP它看起来是这样的填充可以减少ImageView中的图标大小
我的ImageView XML
<ImageView
android:id="@+id/institute_search_item_request_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="20dp"
android:layout_marginTop="15dp"
android:background="@drawable/request_institute_red_icon__shape"
android:foreground="@drawable/ripple_foreground"
android:padding="12dp"
android:src="@drawable/ic_link_white_24dp" />
request_institute_red_icon__shape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/colorPrimary" />
和ripple_foreground.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@color/colorPrimary" />
</shape>
</item>
答
取出填充物,它会缩小你的图标。 在你imageview
只需添加此行得到连锁反应
android:foreground="?attr/selectableItemBackground"
要获得椭圆形波纹:
round_background.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/colorAccent"
android:radius="your_radius" // try radius
tools:targetApi="lollipop">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@color/colorPrimary" />
</shape>
</item>
<item android:drawable="@drawable/red_background" />
</ripple>
red_background.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/red_color"/>/>
</shape>
为什么你需要填充? –
使用保证金做到这一点。 –
@ Bhuvanesh我想要图标周围的波纹颜色。如果我犯了一些愚蠢的错误,请纠正我的错误 – FaisalAhmed