zoukankan      html  css  js  c++  java
  • Android动态设置android:drawableLeft|Right|Top|Bottom 并根据分辨率自适应

    http://blog.sina.com.cn/s/blog_4b93170a0102e1m9.html

    //调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示 最主要一点,不然不显示图片,搞了半天

    /**
             * 从png文件得到Bitmap
             * 并且将尺寸调整为宽=w、高=h
             */
            public static Bitmap getMyBitmap(String imageName, int w, int h){
                    String filePath = IMAGE_PATH + "/" + imageName + ".png";
                    Bitmap oldbmp = BitmapFactory.decodeFile(filePath);
                    if(oldbmp!=null){
                            int width = oldbmp.getWidth();
                            int height = oldbmp.getHeight();
                            Matrix matrix = new Matrix();
                            float scaleWidth = ((float) w / width);
                            float scaleHeight = ((float) h / height);
                            matrix.postScale(scaleWidth, scaleHeight);
                            Bitmap newbmp = Bitmap.createBitmap(oldbmp, 0, 0, width, height, matrix, true);
                            return newbmp;
                    }
                    else{
                            return null;
                    }
            }

    调整分辨率

    http://blog.sina.com.cn/s/blog_4607d856010125sl.html BitmapDrawable的使用转换

  • 相关阅读:
    IE6不支持hover赋予css样式的解决方法 如div:hover li:hover支持
    导航条
    check的css样式
    css3网站
    时间轴滚动充盈
    html5网站
    图片查看插件
    响应式列表中控制图片高度一致js
    json数组按xxx属性值排序 升序
    H5响应式方案
  • 原文地址:https://www.cnblogs.com/zwl12549/p/3485876.html
Copyright © 2011-2022 走看看