java – Android:程序上的纹理背景

我目前正在创建一个 Android应用程序,其中有人可以输入他们的名字,按一个按钮,然后只是输出他们的名字.

我想要实现的一个效果是这样的效果,在他们按下按钮之后,输入和按钮将消失(到目前为止完成这一点),然后MainActivity的视图的背景颜色将会产生波纹(从中心),新颜色,最终改变了完整的背景颜色.

我如何以编程方式进行此操作,因为我只能在按下时找到关于在按钮上添加波纹的教程?

解决方法

编辑:

我通过制作一个小应用程序进行了测试

首先隐藏您想在此动画中显示的视图.

该视图可以来自相同的布局,而在xml中,其可见性应该是不可见的,以便动画将显示它.

如果要创建全屏动画,您可以将视图的高度和宽度设置为与父对象相匹配

以帧格式布置您的原始和显示视图

在我的情况下,我用过这个:

<FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView android:text="Hello World!"                    
                android:layout_width="wrap_content"
                android:textSize="20sp"
                android:layout_height="wrap_content" />
            <LinearLayout 
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorPrimaryDark"
            android:id="@+id/revealiew"
            android:visibility="invisible"
            >
</FrameLayout>

然后在你的活动按钮点击或一些事情做这个:

fab.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void onClick(View view) {
                // previously invisible view
                View myView = findViewById(R.id.revealview);

// get the center for the clipping circle
                int cx = myView.getWidth() / 2;
                int cy = myView.getHeight() / 2;

// get the final radius for the clipping circle
                int finalRadius = Math.max(myView.getWidth(),myView.getHeight());

// create the animator for this view (the start radius is zero)
                Animator anim =
                        ViewAnimationUtils.createCircularReveal(myView,cx,cy,finalRadius);

                //Interpolator for giving effect to animation
                anim.setInterpolator(new AccelerateDecelerateInterpolator());
                // Duration of the animation
                anim.setDuration(1000);

// make the view visible and start the animation
                myView.setVisibility(View.VISIBLE);
                anim.start();
            }
        });
    }

您可以在这里详细了解官方文档:
http://developer.android.com/training/material/animations.html

以上是来客网为你收集整理的java – Android:程序上的纹理背景全部内容,希望文章能够帮你解决java – Android:程序上的纹理背景所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。