Android TV常用动画的效果,View选中变大且有阴影(手机也能用)

转载请标明原地址:http://blog.csdn.net/gaolei1201/article/details/39057057
因为电视屏幕比较大,而我们看电视时距离电视有一定距离,这样就需要动画效果比较明显,这个动画就是应用最广泛的,因为很酷,呵呵,你懂得,看了就知道。

效果如下图:


public class MainActivity extends Activity {
 //下面这三个ImageView是阴影效果
    ImageView mGlobalFloatView;
    ImageView mGlobalShadowView;
    ImageView mGlobalFocusView;
//下面这六个View是六个要选择的对象
    View mSetAppView;
    View mSetDisplayView;
    View mSetEthView;
    View mSetMoreView;
    View mSetUpgradeView;
    View mSetWifiView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mGlobalFloatView = (ImageView) findViewById(R.id.global_imageView_float);
        mGlobalShadowView = (ImageView) findViewById(R.id.global_imageView_shadow);
        mGlobalFocusView = (ImageView) findViewById(R.id.global_imageView_focus);

        mSetAppView = findViewById(R.id.layout_app);
        mSetDisplayView = findViewById(R.id.layout_display);
        mSetEthView = findViewById(R.id.layout_eth);
        mSetMoreView = findViewById(R.id.layout_more);
        mSetUpgradeView = findViewById(R.id.layout_upgrade);
        mSetWifiView = findViewById(R.id.layout_wifi);

        OnFocusChangeListener focuseChangeListener = new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                //调用导入自己写的jar包的AnimationProvider类,如果想看代码可以反编译一下,哈哈
                AnimationProvider.applyAnimation(MainActivity.this, hasFocus, v, mGlobalFocusView,
                        mGlobalFloatView, mGlobalShadowView);
            }
        };

        mSetAppView.setOnFocusChangeListener(focuseChangeListener);
        mSetDisplayView.setOnFocusChangeListener(focuseChangeListener);
        mSetEthView.setOnFocusChangeListener(focuseChangeListener);
        mSetMoreView.setOnFocusChangeListener(focuseChangeListener);
        mSetUpgradeView.setOnFocusChangeListener(focuseChangeListener);
        mSetWifiView.setOnFocusChangeListener(focuseChangeListener);
        OnClickListener clickListener = new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = null;
                switch (v.getId()) {
                    
//下面分别跳转到系统设置的不同地方
                      case R.id.layout_app:
                        intent = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
                        break;
                    case R.id.layout_display:
                        intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
                        break;
                    case R.id.layout_eth:
                        intent = new Intent("android.settings.ETHERNET_SETTINGS");
                        break;
                    case R.id.layout_more:
                        intent = new Intent(Settings.ACTION_SETTINGS);
                        break;
                    case R.id.layout_upgrade:
                        intent = new Intent("android.intent.action.ccdt.ota");
                        break;
                    case R.id.layout_wifi:
                        intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
                        break;

                    default:
                        break;
                }
                try {
                    if (intent != null) {
                        startActivity(intent);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };

        mSetAppView.setOnClickListener(clickListener);
        mSetDisplayView.setOnClickListener(clickListener);
        mSetEthView.setOnClickListener(clickListener);
        mSetMoreView.setOnClickListener(clickListener);
        mSetUpgradeView.setOnClickListener(clickListener);
        mSetWifiView.setOnClickListener(clickListener);
    }

    @Override
    protected void onDestroy() {
        AnimationProvider.reset();
        super.onDestroy();
    }



}



                                               源码地址,点击下载......

©️2020 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值