zoukankan      html  css  js  c++  java
  • android ImageView 视屏幕情况 使图片在限定范围内进行缩放显示

    例如图片默认大小为: 380 * 380

    常规处理:因界面显示区域有限 可以使其让其按 100 * 100 大小显示 则图片会缩小
              则不论屏幕大小 图片都只能这样显示

    灵活处理:使图片在限定范围内进行最佳显示
              一方面 可显示区域够大时 限定最大不超过原始大小 不做放大显示
              另一方面 显示区域不够时 根据控件的可显示范围 进行缩放显示          

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="fill_parent"
     android:layout_height="fill_parent">

     <!-- 固定显示大小  --> 
     <ImageView android:id="@+id/imageView1" 
      android:src="@drawable/photo2"
      android:layout_height="@dimen/photoImageSizeWidth2"
      android:layout_width="@dimen/photoImageSizeWidth2" 
      android:scaleType="fitXY"
      android:layout_gravity="center_horizontal"></ImageView>

     <!-- 视情况在限定范围内进行最佳显示 --> 
     <ImageView android:id="@+id/imageView2"
      android:src="@drawable/photo2"
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content"
      android:adjustViewBounds="true"
      android:maxWidth="380dip" android:maxHeight="380dip"
      android:layout_margin="50dip" android:scaleType="fitXY"
      android:layout_gravity="center_horizontal"></ImageView>
    </LinearLayout>

     

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <dimen name="photoImageSizeWidth2">100dip</dimen>
        <dimen name="photoImageSizeHight2">100dip</dimen>
    </resources>
  • 相关阅读:
    如何进行简单画图
    缓冲技术
    信号量机制
    进程通信
    中断技术
    操作系统原理-图书主题
    供多处理器系统中的高速缓存同步中使用的转发状态
    js几种escape()解码与unescape()编码
    MySQL 元数据
    MySQL 复制表
  • 原文地址:https://www.cnblogs.com/freeliver54/p/2701222.html
Copyright © 2011-2022 走看看