【发布时间】:2015-08-25 23:16:40
【问题描述】:
如何应用像this这样的涟漪效果
我已将依赖项放在 app/build.gradle 中
app/build.gradle
dependencies {
compile 'com.github.traex.rippleeffect:library:1.3'
}
build.gradle
allprojects{
repositories{
jcenter()
maven(url "https://jitpack.io" }
XML 文件:
<com.andexert.library.RippleView
android:id="@+id/rect1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/enterButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save your user name" />
</com.andexert.library.RippleView>
Java 类文件
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.save_user);
editText=(EditText) findViewById(R.id.userNameEditText);
button=(Button) findViewById(R.id.enterButton);
sharedPreferences=getSharedPreferences(SHARED_NAME_STRING, MODE_PRIVATE);
String userNameString=sharedPreferences.getString(USER_NAME_STRING, "");
editText.setText(userNameString);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String string=editText.getText().toString();
Intent intent=new Intent(SaveUser.this, MainActivity.class);
intent.putExtra("user", string);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString(USER_NAME_STRING, string);
editor.commit();
startActivity(intent);
}
});
}
它有效,但我的问题是在涟漪效果完成之前打开另一个活动,当我按下返回按钮时,剩余的涟漪完成。怎么解决??
【问题讨论】: