关于ImageView加载图片的问题

happios 2015-07-29 10:51:24
最近在实现使用ImageView显示图片,发现一个很诡异的问题:当使用imageView加载一些长条形的图片的时候,比如微博上的长微博这种,会出现图片无法显示的情况。事实上列表中的图片大小的空间已经出现了,也就是说,ImageView已经获取到图片的height和width了,不知道为什么就是无法显示图片。
关于图片处理的方式如下:检测本地缓存是否有图片,有的话使用BitmapFactory.decodefile生成bitmap,使用ImageView加载,本地没有图片的话,使用asynctask异步下载,完成后再进行加载。很简单的处理。
因此我推测可能是imageView.setimageBitmap或者BitmapFactory.decodefile的问题。请问这两个方法实现的时候对图片本身的长宽或者文件大小有没有限制?
...全文
203 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyy541 2016-07-14
  • 打赏
  • 举报
回复
我的图片是360度全景图,根本不显示,能不能分享一下,感谢!!
zyy541 2016-07-14
  • 打赏
  • 举报
回复
怎么解决的啊 ?我也遇到了 ,搞不定
sinat_23211887 2016-04-20
  • 打赏
  • 举报
回复
发现问题你是了怎样解决的 急用
happios 2015-07-29
  • 打赏
  • 举报
回复
引用 5 楼 sdliubo 的回复:
猜想有可能是几个原因: 1.尺寸问题只显示了部分,试试加上:android:scaleType="fitXY" 2.内存不够换个机器试试看 3.确认一下是放在src中的不是放在background中的
1.并不是显示部分,而是长条图片整张都没有显示。 2.测试机子内存2g 3.无误,并且只有长条图片出现这种问题,其他图片能正常显示
sdliubo 2015-07-29
  • 打赏
  • 举报
回复
猜想有可能是几个原因: 1.尺寸问题只显示了部分,试试加上:android:scaleType="fitXY" 2.内存不够换个机器试试看 3.确认一下是放在src中的不是放在background中的
happios 2015-07-29
  • 打赏
  • 举报
回复
引用 2 楼 gao_chun 的回复:
没有限制的,找找其他的原因,确认图片是否存在
确认存在,已查看过缓存文件夹,图片能正常下载,正常缓存,另外imageview能够分配一个图片大小的空间。
happios 2015-07-29
  • 打赏
  • 举报
回复
引用 1 楼 u013377714 的回复:
你的长条形图片会不会有一长段透明的看不到的,其实已经显示出来了。
对,就像你说的一样,图片大小的长条空白空间已经出来了,就是看不到图片
gao_chun 2015-07-29
  • 打赏
  • 举报
回复
没有限制的,找找其他的原因,确认图片是否存在
水的川 2015-07-29
  • 打赏
  • 举报
回复
你的长条形图片会不会有一长段透明的看不到的,其实已经显示出来了。
JPF1024 2015-07-29
  • 打赏
  • 举报
回复
引用 11 楼 happios 的回复:
ok,刚刚没注意看,发现报了一个warning: 07-29 14:46:46.614: W/OpenGLRenderer(7378): Bitmap too large to be uploaded into a texture (440x5301, max=4096x4096) http://blog.csdn.net/gxhesihong/article/details/10005617 果然是大小限制的原因,但不是imageview,而是硬件加速的锅。 已解决,谢谢各位大大
嗯,也学习了。
happios 2015-07-29
  • 打赏
  • 举报
回复
ok,刚刚没注意看,发现报了一个warning: 07-29 14:46:46.614: W/OpenGLRenderer(7378): Bitmap too large to be uploaded into a texture (440x5301, max=4096x4096) http://blog.csdn.net/gxhesihong/article/details/10005617 果然是大小限制的原因,但不是imageview,而是硬件加速的锅。 已解决,谢谢各位大大
happios 2015-07-29
  • 打赏
  • 举报
回复
主要是account_pic和quote_pic这两个imageview,其实布局文件没什么东西
happios 2015-07-29
  • 打赏
  • 举报
回复
引用 7 楼 u013377714 的回复:
[quote=引用 3 楼 happios 的回复:] [quote=引用 1 楼 u013377714 的回复:] 你的长条形图片会不会有一长段透明的看不到的,其实已经显示出来了。
对,就像你说的一样,图片大小的长条空白空间已经出来了,就是看不到图片[/quote]把你的imageview的xml文件晒一下。。[/quote]
引用 8 楼 boatwater 的回复:
看下布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:gravity="center"
    android:padding="5dp"
    card_view:cardCornerRadius="6dp" >

    <LinearLayout
        android:id="@+id/main_item"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:padding="5dp" >

        <LinearLayout
            android:id="@+id/users"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical" 
            android:paddingTop="10dp"
            >

            <ImageView
                android:id="@+id/user_avatar"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_gravity="center"
                android:src="@drawable/weibo_64x64" />

            <TextView
                android:id="@+id/users_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:paddingTop="10dp"
                android:text="name"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/user_stair_num"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0"
                android:layout_gravity="bottom"
                android:gravity="bottom"
                android:textAppearance="?android:attr/textAppearanceSmall" />

        </LinearLayout>

        <LinearLayout
            android:id="@+id/account"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/account_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="text" />

            <ImageView
                android:id="@+id/account_pic"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="start"
                android:src="@drawable/ic_launcher" />

            <GridView
                android:id="@+id/account_pics"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:numColumns="3" >
            </GridView>

            <LinearLayout
                android:id="@+id/quote"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#55555555"
                android:orientation="vertical"
                android:padding="5dp" >

                <TextView
                    android:id="@+id/quote_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="name"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/quote_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="text" />

                <ImageView
                    android:id="@+id/quote_pic"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_launcher" />

                <GridView
                    android:id="@+id/quote_pics"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:numColumns="3" >
                </GridView>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

</android.support.v7.widget.CardView>

boatwater 应用层 2015-07-29
  • 打赏
  • 举报
回复
看下布局文件
水的川 2015-07-29
  • 打赏
  • 举报
回复
引用 3 楼 happios 的回复:
[quote=引用 1 楼 u013377714 的回复:] 你的长条形图片会不会有一长段透明的看不到的,其实已经显示出来了。
对,就像你说的一样,图片大小的长条空白空间已经出来了,就是看不到图片[/quote]把你的imageview的xml文件晒一下。。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧