如何使用 RippleView 创建涟漪?
How to use RippleView to create ripples?
我试图在使用 RippleEffect project 单击我的按钮时产生涟漪,但是每次我 运行 代码时应用程序都会崩溃。我该如何解决?或者,有没有一种更简单的方法可以在单击按钮时产生涟漪?如果可能请帮忙。谢谢!
<RelativeLayout
android:id="@+id/topPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.andexert.library.RippleView
android:layout_width="match_parent"
android:layout_height="95dp">
// Button 1
<Button
android:id="@+id/name1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="95dp"
android:gravity="center"
android:background="@drawable/button_border"
android:textSize="17dp"
android:textAllCaps="false"
android:textStyle="normal|bold" />
// TIME 1
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/name1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="4dp"
android:textSize="18dp"
android:textColor="@android:color/darker_gray"
android:elevation="2dp"
android:id="@+id/editText1" />
// NAME 1
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text=" "
android:elevation="2dp"
android:layout_alignBaseline="@+id/name1"
android:layout_alignBottom="@+id/name1"
android:layout_centerHorizontal="true"
android:cursorVisible="false" />
</com.andexert.library.RippleView>
</RelativeLayout> // End Left Side
只是为了检查 sample codes
模仿 Android L.
中引入的点击涟漪效应的视图
对于工作实施,请查看示例项目 - RippleViewExample
将库作为本地库项目包含在内。
在您的布局中包含 RippleView 小部件。
在您的 onCreate 方法中引用视图并添加 'OnClickListener' 相同。
mButton = (RippleView) findViewById(R.id.btn);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//your code
}
});
我试图在使用 RippleEffect project 单击我的按钮时产生涟漪,但是每次我 运行 代码时应用程序都会崩溃。我该如何解决?或者,有没有一种更简单的方法可以在单击按钮时产生涟漪?如果可能请帮忙。谢谢!
<RelativeLayout
android:id="@+id/topPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.andexert.library.RippleView
android:layout_width="match_parent"
android:layout_height="95dp">
// Button 1
<Button
android:id="@+id/name1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="95dp"
android:gravity="center"
android:background="@drawable/button_border"
android:textSize="17dp"
android:textAllCaps="false"
android:textStyle="normal|bold" />
// TIME 1
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/name1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="4dp"
android:textSize="18dp"
android:textColor="@android:color/darker_gray"
android:elevation="2dp"
android:id="@+id/editText1" />
// NAME 1
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18dp"
android:text=" "
android:elevation="2dp"
android:layout_alignBaseline="@+id/name1"
android:layout_alignBottom="@+id/name1"
android:layout_centerHorizontal="true"
android:cursorVisible="false" />
</com.andexert.library.RippleView>
</RelativeLayout> // End Left Side
只是为了检查 sample codes
模仿 Android L.
中引入的点击涟漪效应的视图对于工作实施,请查看示例项目 - RippleViewExample
将库作为本地库项目包含在内。
在您的布局中包含 RippleView 小部件。
在您的 onCreate 方法中引用视图并添加 'OnClickListener' 相同。
mButton = (RippleView) findViewById(R.id.btn);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//your code
}
});