Android GridView stretchMode with Async ImageView Loading -
i have following gridview defined w/stretchmode set "columnwidth".
<gridview android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="wrap_content" android:columnwidth="160dp" android:numcolumns="auto_fit" android:verticalspacing="10dp" android:horizontalspacing="10dp" android:stretchmode="columnwidth" android:listselector="@drawable/list_selector" /> each item in gridview structured follows.
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="2dp" > <framelayout android:layout_width="match_parent" android:layout_height="wrap_content" > <imageview android:id="@+id/videogriditemimage" android:layout_width="match_parent" android:layout_height="wrap_content" android:adjustviewbounds="true" /> <textview android:id="@+id/videogriditemduration" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="#88000000" android:textcolor="#f1f1f1" android:textappearance="@android:style/textappearance.small" android:padding="2dp" /> </framelayout> <textview android:id="@+id/videogriditemtitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="left" android:textappearance="@android:style/textappearance.medium" android:textcolor="#f1f1f1" android:maxlines="1" android:background="#88000000" android:paddingleft="2dp" android:paddingright="2dp" /> <textview android:id="@+id/videogriditemsubtitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="left" android:textstyle="italic" android:textcolor="#666" android:textappearance="@android:style/textappearance.small" android:maxlines="1" android:background="#88000000" android:paddingleft="2dp" android:paddingright="2dp" /> </linearlayout> in gridview's adapter, i'm async loading , displaying images passing url , reference of imageview dedicated class. class downloads image bitmap , updates imageview using setimagebitmap(). workflow functions expected; however, images aren't filling entire width of imageview. there's small amount of paddding on left/right sides. realize can use scaletype="fitxy", isn't ideal skews images. setting src attribute of imageview local image scales fine stretchmode="columnwidth". guess imageview scaling original columnwidth , not stretched/dynamic width. have insight why occurring and/or how fix? in advance help.
you have 2 options:
set imageview's layout_width wrap_content. imageview resize based on size of image , column adjust accordingly.
set imageview's scaletype centercrop. try fit image imageview without skewing , cut off excess doesn't fit. leave no blank space.
Comments
Post a Comment