• LevelListDrawable


    用来管理一组Drawable的,我们可以为里面的drawable设置不同的level, 当他们绘制的时候,会根据level属性值获取对应的drawable绘制到画布上,根节点 为:<level-list>他并没有可以设置的属性,我们能做的只是设置每个<item> 的属性!

    item可供设置的属性如下

    • drawable:引用的位图资源,如果为空徐璈有一个Drawable类型的子节点
    • minlevel:level对应的最小值
    • maxlevel:level对应的最大值

    通过shapeDrawable画圆,一式五份,改下宽高即可:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <solid android:color="#2C96ED"/>
        <size android:height="20dp" android:width="20dp"/>
    </shape>

    level_cir.xml

    <?xml version="1.0" encoding="utf-8"?>
    <level-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item android:drawable="@drawable/shape_cir1" android:maxLevel="2000"/>
        <item android:drawable="@drawable/shape_cir2" android:maxLevel="4000"/>
        <item android:drawable="@drawable/shape_cir3" android:maxLevel="6000"/>
        <item android:drawable="@drawable/shape_cir4" android:maxLevel="8000"/>
        <item android:drawable="@drawable/shape_cir5" android:maxLevel="10000"/>
    </level-list> 
    public class MainActivity extends AppCompatActivity {
    
        private ImageView img_show;
    
        private LevelListDrawable ld;
        private Handler handler = new Handler() {
            public void handleMessage(Message msg) {
                if (msg.what == 0x123) {
                    if (ld.getLevel() > 10000) ld.setLevel(0);
                    img_show.setImageLevel(ld.getLevel() + 2000);
                }
            }
        };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            img_show = (ImageView) findViewById(R.id.img_show);
            ld = (LevelListDrawable) img_show.getDrawable();
            img_show.setImageLevel(0);
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    handler.sendEmptyMessage(0x123);
                }
            }, 0, 100);
        }
    }
  • 相关阅读:
    Bootstrap-datepicker3官方文档中文翻译---Methods/方法(原文链接 http://bootstrap-datepicker.readthedocs.io/en/latest/index.html)
    Bootstrap-datepicker3官方文档中文翻译---Options/选项(原文链接 http://bootstrap-datepicker.readthedocs.io/en/latest/index.html)
    IOI2020集训队作业
    校内集训作业题
    CF题目泛做 3
    CF题目泛做 2
    CF题目泛做1
    NOIP2020
    相邻交换法 & 皇后游戏
    Codeforces Round #679 Div.1
  • 原文地址:https://www.cnblogs.com/loaderman/p/10169382.html
Copyright © 2020-2023  润新知