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>
  • 相关阅读:
    Java--数组转成list,list转数组
    js禁用后退
    正则
    实用符号Alt+小键盘快输
    Minimum Depth of Binary Tree
    Balanced Binary Tree
    Valid Palindrome [leetcode]
    Sum Root to Leaf Numbers
    reorder List
    判断链表 有环
  • 原文地址:https://www.cnblogs.com/20193898liufa/p/14908586.html
Copyright © 2011-2022 走看看