Tag: rippledrawable

棒棒糖RippleDrawable与select器的前棒棒糖

我有不同的draw9patch png作为背景的button。 目前button由selector控制,如下所示: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/pressed" android:state_pressed="true"/> <item android:drawable="@drawable/disabled" android:state_enabled="false"/> <item android:drawable="@drawable/focused" android:state_focused="true"/> <item android:drawable="@drawable/default"/> </selector> 对于Android棒棒糖,他们有一个RippleDrawable触摸效果,这是这样的: <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item> … </item> </ripple> 对于新的触摸涟漪效应: 1:我可以将draw9patch设置为RippleDrawable背景吗? 2:如何容纳上面两种不同的xml我想遵循材质devise? 我必须为新的RippleDrawable分出一个新的文件夹/布局xml吗?

如何设置state_selected在波纹drawable

如何在android:state_selected指定android:state_selected state_selected 我有以下的XML纹波绘制,但背景颜色不显示时,我设置myView.setSelected(true); <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#DDDDDD" > <item android:id="@android:id/mask"> <shape> <solid android:color="@color/black" /> </shape> </item> <item android:state_selected="true"> <shape> <solid android:color="#EEEEEE" /> </shape> </item> <item> <color android:color="#FFFFFF" /> </item> </ripple>

如何在简单的布局创build涟漪效应

触摸布局时,如何在简单线性/相对布局中产生连锁效应? 我已经尝试设置布局的背景如下所示: <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight" > <item android:drawable="@android:color/white"/> </ripple> 不过,我只看到纯白色的背景,触摸布局时没有涟漪效应。 我究竟做错了什么? 编辑: 作为参考,这里是我的布局xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="250dp" android:layout_height="250dp" android:background="@drawable/test" android:clickable="true"> </RelativeLayout>

Listviewselect器与彩色背景和波纹效果

在Android L开发人员预览中的标准ListViewselect器使用colorControlHighlight触摸的涟漪效应,并在未聚焦状态下具有透明背景。 我想定义一个具有彩色背景的ListView项目,并且仍然使用相同的高亮颜色显示触摸时的涟漪效果。 现在,如果我定义下面的drawable: <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item android:drawable="@color/my_background_color"/> </ripple> 它可以工作,但是无论触摸位置如何,纹波都始于ListView项目的中间。 如果我在ListView之外使用相同的背景,例如LinearLayout ,它的工作方式与预期相同(纹波从触摸位置开始)。

点击时如何在button上制作一个圆形的波纹?

背景 在Android的拨号器应用程序中,当您开始search某些内容时,单击EditText左侧的箭头button,您会得到一个循环的连锁反应: 问题 我也尝试过,但我有一个长方形的: <ImageButton android:id="@+id/navButton" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="center_vertical" android:layout_marginLeft="8dp" android:background="?android:attr/selectableItemBackground" android:src="@drawable/search_ic_back_arrow"/> 这个问题 点击时如何使button有一个圆形的涟漪效应? 我是否需要创build一个新的drawable,还是有内置的方法?

使用RecyclerView和CardView触摸反馈

我很想为我的开源库启用触摸反馈。 我创build了一个RecyclerView和一个CardView 。 CardView包含具有不同onClick操作的不同区域。 现在,如果用户点击卡片中的任意位置,我很乐意触发Ripple效果,但是我无法实现此行为。 这是我的listitem,你也可以在GitHub上find它: https : //github.com/mikepenz/AboutLibraries/blob/master/library/src/main/res/layout/listitem_opensource.xml <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:clickable="true" android:background="@drawable/button_rect_normal"/> <LinearLayout android:padding="6dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:gravity="center_vertical" android:paddingLeft="8dp" android:paddingRight="8dp" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/libraryName" android:textColor="@color/title_openSource" android:textSize="@dimen/textSizeLarge_openSource" android:textStyle="normal" android:layout_width="0dp" android:layout_weight="5" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1"/> <TextView android:id="@+id/libraryCreator" android:textColor="@color/text_openSource" android:textStyle="normal" android:layout_width="0dp" android:layout_weight="2" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="right" android:maxLines="2" android:textSize="@dimen/textSizeSmall_openSource"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:layout_marginTop="4dp" android:background="@color/dividerLight_openSource"/> <TextView android:id="@+id/libraryDescription" […]

Android的涟漪效应 – 触摸button反馈 – 使用XML

我正试图了解如何实现button和其他视图的“纹波效果 – 触摸反馈”。 我看了一下SO上Ripple touch效果的问题,并对其进行了一些了解。 我能够使用这个Java代码成功地获得连锁反应。 import android.animation.ObjectAnimator; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RadialGradient; import android.graphics.Region; import android.graphics.Shader; import android.support.annotation.NonNull; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.animation.AccelerateInterpolator; import android.widget.Button; public class MyButton extends Button { private float mDownX; private float mDownY; private float mRadius; private Paint mPaint; public MyButton(final Context […]