zoukankan      html  css  js  c++  java
  • android 让图片充满整个屏幕

    方法1:

    <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:scaleType="fitXY"
            android:src="@drawable/lbhao" />
    
    以上是代码:只需加入在ImageView中加入这个代码即可android:scaleType="fitXY"

    方法2:

    public static Bitmap FitTheScreenSizeImage(Bitmap m,int ScreenWidth, int ScreenHeight)
    {
            float width  = (float)ScreenWidth/m.getWidth();
            float height = (float)ScreenHeight/m.getHeight();
            Matrix matrix = new Matrix();
            matrix.postScale(width,height);
            return Bitmap.createBitmap(m, 0, 0, m.getWidth(), m.getHeight(), matrix, true);
     }
    float width  = (float)ScreenWidth/m.getWidth();        屏宽/图宽
    float height = (float)ScreenHeight/m.getHeight();    屏高/图高
    Matrix matrix = new Matrix();                矩阵对象
    matrix.postScale(width,height);            把缩放系数传入该对象中
    return Bitmap.createBitmap(m, 0, 0, m.getWidth(), m.getHeight(), matrix, true);        创建一张图片
    参数分别是:
    图片对象、x、y、w、h、矩阵对象、是否开启抗锯齿
    
    setContentView(FitTheScreenSizeImage(R.drawable.welcomeview,screenWidth,screenHeigh));}
  • 相关阅读:
    快速幂
    1112个人赛,最长回文串常见算法讨论
    11-05-sdust-个人赛赛后随想
    UVA 1149 Bin Packing
    UVa 1608,Non-boring sequences
    UVa 10954,Add All
    UVa 714,Copying Books
    Careercup
    Careercup
    Careercup
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4554744.html
Copyright © 2011-2022 走看看