GridView不能显示图片[英] GridView cannot show image

本文是小编为大家收集整理的关于GridView不能显示图片的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我得到所有应用程序的图标,并在gridview中显示图标. GridView非常好,但是当我快速地向下滑动GridView时,有时缺少GridView的两个图标.这种情况不经常出现,你能给我一些建议.

编辑:此问题已被问到之前,但没有答案. 滚动问题在Android

推荐答案

我已经解决了我的情况,在我使用这些XML的GridView的适配器中显示图像和文本:

<!--  <LinearLayout android:layout_width="fill_parent"  android:layout_height="18dip"  /> -->
    <LinearLayout
            android:id="@+id/iconBackgroundLinear"
            android:layout_width="54dip"
            android:layout_height="57dip"
            android:gravity="center">

        <ImageView
                android:id="@+id/app_icon"
                android:layout_width="45dip"
                android:layout_height="45dip"
                android:adjustViewBounds="false"
                />
    </LinearLayout>

    <TextView
            android:id="@+id/app_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="2dip"
            android:gravity="center_horizontal"
            android:lines="2"
            />
    </LinearLayout>

键是 android:行="2",当我使用 android:maxline ="2",它可能会显示上面的错误.

其他推荐答案

我已经解决了这个问题所取代的

<LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="@dimen/big_margin"
    android:layout_width="match_parent"
    android:layout_marginLeft="@dimen/big_margin"
    android:layout_height="wrap_content">

<LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="@dimen/big_margin"
    android:layout_width="match_parent"
    android:layout_marginLeft="@dimen/big_margin"
    android:layout_height="@dimen/workoutlist_itemheight">

但真的我不知道我的问题是如何解决的.

感谢

本文地址:https://www.itbaoku.cn/post/102707.html

问题描述

I get all application's icons, and show the icons in GridView. The GridView shows them very well, but when I glides the GridView very fast to downward, sometimes lack of two icons at GridView. This kind of situation not often appears, can you give me some advice.

EDIT : this question have been asked before, but no answers. Scrolling issues with GridView in Android

推荐答案

I have solved it, in my situation, in the adapter of GridView that I used these XML to show image and text:

<!--  <LinearLayout android:layout_width="fill_parent"  android:layout_height="18dip"  /> -->
    <LinearLayout
            android:id="@+id/iconBackgroundLinear"
            android:layout_width="54dip"
            android:layout_height="57dip"
            android:gravity="center">

        <ImageView
                android:id="@+id/app_icon"
                android:layout_width="45dip"
                android:layout_height="45dip"
                android:adjustViewBounds="false"
                />
    </LinearLayout>

    <TextView
            android:id="@+id/app_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="2dip"
            android:gravity="center_horizontal"
            android:lines="2"
            />
    </LinearLayout>

The key is android:lines="2", when I am using android:maxline="2" , it may show above mistake.

其他推荐答案

i have solved this problem replaced by

<LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="@dimen/big_margin"
    android:layout_width="match_parent"
    android:layout_marginLeft="@dimen/big_margin"
    android:layout_height="wrap_content">

to

<LinearLayout
    android:orientation="horizontal"
    android:layout_marginTop="@dimen/big_margin"
    android:layout_width="match_parent"
    android:layout_marginLeft="@dimen/big_margin"
    android:layout_height="@dimen/workoutlist_itemheight">

but really i don't know how did my issue solved.

thanks