美文网首页
的使用技巧

的使用技巧

作者: 陈大吼 | 来源:发表于2019-12-27 11:30 被阅读0次

首先是原图

test.jpg

bitmap_drawable.xml:查看clip_vertical效果

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/test"
    android:antialias="true"
    android:dither="true"
    android:filter="true"
    android:gravity="clip_vertical"
    android:tileMode="disabled"/>

bitmap_drawable2.xml:查看clip_horizontal效果

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/test"
    android:antialias="true"
    android:dither="true"
    android:filter="true"
    android:gravity="clip_horizontal"
    android:tileMode="disabled"/>

bitmap_drawable3.xml:查看clamp效果

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/test"
    android:antialias="true"
    android:dither="true"
    android:filter="true"
    android:tileMode="clamp"/>

bitmap_drawable4.xml:查看mirror效果

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/test"
    android:antialias="true"
    android:dither="true"
    android:filter="true"
    android:tileMode="mirror"/>

test.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <FrameLayout
        android:layout_width="50dp"
        android:layout_height="100dp"
        android:background="@drawable/bitmap_drawable" />

    <FrameLayout
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:background="@drawable/bitmap_drawable2">
    </FrameLayout>

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/bitmap_drawable3">
    </FrameLayout>
</LinearLayout>

test.xml的效果图:


Lark20191227112410.png

可以看到:clip_vertical时,图片等比例缩放(这里是缩小)后,纵向填满,横向被切;
clip_horizontal时,图片等比例缩放(这里是缩小)后,横向填满,纵向被切;
clamp情况下,图片四周(本例中只有底部有未填充的区域)的最后一个像素的颜色被重复填充在控件未填充的区域

将最后一个FrameLayout 的background 改为bitmap_drawable4
效果图为:


Lark20191227112435.png

mirror情况下,图片四周(本例中只有底部有未填充的区域)以镜像方式重复填充在控件未填充的区域

相关文章

  • 的使用技巧

    首先是原图 bitmap_drawable.xml:查看clip_vertical效果 bitmap_drawab...

  • android内存优化

    1、Bitmap优化:bitmap是造成oom的最大威胁可以用通过一些小技巧如:使用适当分辨率和大小的图片,即使内...

  • Bitmap详解

    Bitmap的分析与使用 Bitmap的创建创建Bitmap的时候,Java不提供new Bitmap()的形式去...

  • Bitmap的分析与使用

    Bitmap的分析与使用 Bitmap的创建创建Bitmap的时候,Java不提供new Bitmap()的形式去...

  • EaselJS图片处理

    Bitmap 使用Bitmap类可以非常方便的处理图片,Bitmap可以用来代表任何形式,比如,Canvas,视频...

  • 春招笔记(五)--安卓第二部分

    1.Bitmap的使用 创建Bitmap的时候,Java不提供new Bitmap()的形式去创建,而是通过Bit...

  • Android基础(19)Bitmap

    1)Bitmap对象的理解2)Bitmap 使用时候注意什么?3)Bitmap的recycler()4)一张Bit...

  • Bitmap高效加载及Android缓存策略

    大图加载原理也涉及到了Bitmap的使用。 一、Bitmap(位图)基本概念 1、Bitmap是Android系统...

  • Bitmap

    Bitmap使用需要注意哪些问题 ? 要选择合适的图片规格(bitmap类型):通常我们优化Bitmap时,当需要...

  • Android Bitmap

    Bitmap 1.Bitmap使用需要注意哪些问题? 参考回答:要选择合适的图片规格(bitmap类型):通常我们...

网友评论

      本文标题:的使用技巧

      本文链接:https://www.haomeiwen.com/subject/wdaroctx.html