zoukankan      html  css  js  c++  java
  • 解决scrollview嵌套ImageView时,出现除顶部和底部黑块的问题

    最近一个项目中,从网上下载一个图片,然后展示给用户看,那个图片本来是iphone里的,拿到android上来,一拉伸就出问题了,scrollview的顶部和底部出现了奇怪的黑块,如图:

    在网上找了很资料都没解决,后来在一个外国网站找到结果,分享一下。

    代码:

    <?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"
        >
    <ScrollView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        >
        <ImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/demo"
        android:adjustViewBounds="true"
        android:scaleType="centerInside"></ImageView>
        </ScrollView>
    </LinearLayout>

    android:adjustViewBounds="true"这句很关键

    奉送美女图片一张:/Files/ProgramBull/demo.jpg

  • 相关阅读:
    mybatis+sql语句
    坐标转换
    sql语句含中文JDBC查询不到
    架构阅读笔记16
    架构阅读笔记15
    架构阅读笔记14
    windows安装imgaug包报错中Shapely
    java除法
    Java输入输出问题复习
    java自学,基础,入门
  • 原文地址:https://www.cnblogs.com/ProgramBull/p/2345498.html
Copyright © 2011-2022 走看看