zoukankan      html  css  js  c++  java
  • 3.19

    ImageView为我们提供了adjustViewBounds属性,用于设置缩放时是否保持原图长宽比! 单独设置不起作用,需要配合maxWidthmaxHeight属性一起使用!而后面这两个属性 也是需要adjustViewBounds为true才会生效的。

    代码示例:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <!-- 正常的图片 -->
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5px"
            android:src="@mipmap/meinv" />
        <!-- 限制了最大宽度与高度,并且设置了调整边界来保持所显示图像的长宽比-->
        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5px"
            android:adjustViewBounds="true"
            android:maxHeight="200px"
            android:maxWidth="200px"
            android:src="@mipmap/meinv" />
    
    </LinearLayout>
  • 相关阅读:
    Expression基础体验
    浅谈Pool对象
    TreeBuilder科学的树创建器
    2种负载均衡算法
    亲自打造Deferred对象
    Animation
    micro-template改造
    Node.js的缺陷
    让JSON.js完全适应.NET
    关系型数据库操作一些不好用的地方
  • 原文地址:https://www.cnblogs.com/20193898liufa/p/14908586.html
Copyright © 2011-2022 走看看