26
2017
09

Android button 圆角矩形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <corners  android:bottomLeftRadius="25dp" android:bottomRightRadius="25dp" android:radius="8dp" android:topLeftRadius="25dp" android:topRightRadius="25dp" />
    <!-- <gradient android:angle="45" android:endColor="#72cb60" android:startColor="#72cb60" />-->
    <padding  android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
    <size android:width="100dp" />
    <solid android:color="#999" />
    <stroke  android:width="2dp" android:color="#dcdcdc" />
</shape>

不多说了,自己用就知道了,这里我选择给Button在加一个动画:

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.button1:
                Button1Click(view);
                break;
        }
    }

    private void Button1Click( final View v) {
        ObjectAnimator o=ObjectAnimator.ofFloat(v,"rotationY",1.0F,0.0F,1.0f)
                .setDuration(500);
        o.start();

        o.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedValue = (float) valueAnimator.getAnimatedValue();
                v.setAlpha(animatedValue);
                v.setScaleX(animatedValue);
                v.setScaleY(animatedValue);
            }
        });
    }

还是很不错的!
里面挺多属性动画样式,有兴趣的可以看看:
http://download.csdn.net/download/kururunga/9994328

上一篇:[RK3288][Android6.0] 调试笔记 --- AndroidTool低格无效问题 下一篇:Android延迟界面跳转的方法