zoukankan      html  css  js  c++  java
  • 实现图片缓慢展开功能

    //要用到clipdrawble,xml功能如下,在drawble目录下新建,类型选择为clip(注意AS不会提示)
    <?xml version="1.0" encoding="utf-8"?> <clip xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/a" android:clipOrientation="horizontal" android:gravity="center"> </clip>


    //IMG的XML
    <ImageView
    android:id="@+id/img"
    android:src="@drawable/clip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />






    //JAVA代码如下
    import android.graphics.drawable.ClipDrawable;
    import android.os.Handler;
    import android.os.Message;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.widget.ImageView;

    public class MainActivity extends AppCompatActivity {
    private ImageView img;
    private ClipDrawable clip;
    private MyHandler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    init();
    }

    private void init() {
    img = (ImageView) findViewById(R.id.img);
    clip=(ClipDrawable) img.getDrawable();
    handler=new MyHandler();
    MyThread thread=new MyThread();
    new Thread(thread).start();

    }
    private class MyThread implements Runnable{

    @Override
    public void run() {
    while(true){
    try {
    Message msg=handler.obtainMessage();
    msg.what=0x123;
    msg.sendToTarget();
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }
    }
    private class MyHandler extends Handler{
    @Override
    public void handleMessage(Message msg) {
    super.handleMessage(msg);
    if(msg.what==0x123){
    clip.setLevel(clip.getLevel()+100);
    }
    }
    }
    }
  • 相关阅读:
    enum:python实现枚举也很优雅
    jieba:我虽然结巴,但是我会分词啊
    pyquery:轻松、灵活的处理html
    lxml:底层C语言实现、高效地处理html
    shelve:极其强大的序列化模块
    Session管理之ThreadLocal
    Hibernate之Criteria
    Hibernate之list和iterator
    hibernate之createQuery与createSQLQuery
    C标签之forEach
  • 原文地址:https://www.cnblogs.com/yzjT-mac/p/5818588.html
Copyright © 2011-2022 走看看