如何创建pre-棒棒糖连锁反应 [英] how to create ripple effect for pre-lollipop

查看:155
本文介绍了如何创建pre-棒棒糖连锁反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何申请如连锁反应

我已经把依赖于应用程序/ build.gradle

i have put the dependencies in app/build.gradle

应用程序/ build.gradle

app/build.gradle

dependencies {
    compile 'com.github.traex.rippleeffect:library:1.3'
}

build.gradle

build.gradle

allprojects{
    repositories{
        jcenter()
        maven(url "https://jitpack.io" }

XML文件:

XML file:

<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类文件

Java class file

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);

        }
    });
}

它的工作原理,但我的问题是另一项活动打开了连锁反应完成之前,当我preSS后退按钮剩余纹波完成。我该怎么解决呢?

it works but my problem is another activity opens before the ripple effect completes and when I press back button the remaining ripple completes. how can I solve it??

推荐答案

您可以试试这个库 balysv /材料纹波

在你的摇篮,加入这一行:

In your gradle, add this line :

compile 'com.balysv:material-ripple:1.0.2'

这是如何做到这一点:

And this is how to do it :

<com.balysv.materialripple.MaterialRippleLayout
android:id="@+id/ripple"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="Button inside a ripple"/>
</com.balysv.materialripple.MaterialRippleLayout>

这篇关于如何创建pre-棒棒糖连锁反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆