Android Design

Android Design

    Desgin 介绍

    1.CardView

    android:stateListAnimator="@drawable/touch_raise"
    android:foreground="?android:attr/selectableItemBackground"
    app:cardBackgroundColor="#909090"
    app:cardCornerRadius="10dp"
    app:cardElevation="2dp"
    app:cardMaxElevation="10dp"

        res\drawable\touch_raise.xml

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_enabled="true" android:state_pressed="true">
            <objectAnimator
                android:duration="500"
                android:propertyName="cardElevation"
                android:valueTo="6dp"
                android:valueType="floatType"
                />
        </item>
        <item>
            <objectAnimator
                android:duration="500"
                android:propertyName="cardElevation"
                android:valueTo="2dp"
                android:valueType="floatType"
                />
        </item>
    </selector>

    2.新增动画

        波纹效果(Ripple):当你使用了Material主题后,波纹动画会自动应用在所有的控件上。

            可以设置其属性调整效果:

            android:background=?android:attr/selectableItemBackground波纹有边界

                或

            android:background=?android:attr/selectableItemBackgroundBorderless波纹超出边界

            设置颜色(可以通过设置xml属性来调节动画颜色)

            android:colorControlHighlight   //设置波纹颜色
            android:colorAccent     //设置checkbox等控件的选中颜色

        圆形动画(Circular Reveal):                   

            Animator circularReveal = ViewAnimationUtils.createCircularReveal(mOval, mOval.getWidth() / 2, mOval.getHeight() / 2, mOval.getWidth(), 0);
            /**
            *view 操作的视图 
            *centerX 动画开始的中心点X 
            *centerY 动画开始的中心点Y 
            *startRadius 动画开始半径 
            *startRadius 动画结束半径
            */
            circularReveal.setInterpolator(new AccelerateDecelerateInterpolator()); //设置动画插值器  加速度
            circularReveal.setDuration(1000);
            circularReveal.start();

        3.颜色采集

   BitmapDrawable drawable = (BitmapDrawable) mImage.getDrawable();
   Bitmap bitmap = drawable.getBitmap();
   //Palette  颜色采集
   Palette.Builder from = Palette.from(bitmap);
   //传入默认颜色 如果无法采集到该色值 使用默认
   Palette generate = from.generate();
   int darkVibrantColor = generate.getLightVibrantColor(Color.BLACK);
   //转ARGB
   String s = Integer.toHexString(darkVibrantColor);
   //替换透明度
   String ff = s.replaceFirst("ff", "22");
   //组织颜色
   darkVibrantColor= Color.parseColor("#" + ff);
   // 异步创建
/*   from.generate(new Palette.PaletteAsyncListener() {
       @Override
       public void onGenerated(Palette palette) {
           ARGB
       }
   });*/
   mTitle.setBackgroundColor(darkVibrantColor);

        4.RecyclerView控件

            LayoutManager布局管理器:

        //1、设置布局管理器 ,确认我们的布局管理器
        LinearLayoutManager manager  = new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false);    //LinearLayoutManager 线性管理器
//        GridLayoutManager manager = new GridLayoutManager(this,3,GridLayoutManager.VERTICAL,false);       //GridLayoutManager 网格管理器
//        StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.HORIZONTAL);    //StaggeredGridLayoutManager  交错网格管理器|瀑布流
        mRecycle.setLayoutManager(manager);

            RecycleView.Adapter 适配器:      

class MyAdapter extends RecyclerView.Adapter<MyAdapter.Holder>{    //Adapter.ViewHolder  适配器持有者


    /**
     * 创建ViewHolder
     * @param parent
     * @param viewType
     * @return
     */
    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recycle, parent, false);
        return new Holder(view);
    }

    /**
     * 绑定视图  类似于 getView
     * @param holder
     * @param position
     */
    @Override
    public void onBindViewHolder(Holder holder, int position) {
        holder.text.setText(String.valueOf(position));
    }
    /**
     * 子元素个数
     * @return
     */
    @Override
    public int getItemCount() {
        return 100;
    }

    /**
     * 记录
     */
    class Holder extends RecyclerView.ViewHolder{

        TextView text;

        public Holder(View itemView) {
            super(itemView);
            text = (TextView) itemView.findViewById(R.id.item_text);
        }
    }
}

        5.HeaderAndFooterRecyclerView

转载于:https://my.oschina.net/glfei/blog/780885

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值