/**
* Get screen Width */public
static int getscreenwidth (context context) {
WindowManager manager = ( WindowManager) Context
. Getsystemservice (context.window_service);
Display display = Manager.getdefaultdisplay ();
return Display.getwidth ();
}
public static int Diptopx (context context, int dip) {
if (density <= 0.0F) {
density = context.getresources (). g Etdisplaymetrics (). density;
}
return (int) (float) dip * density + 0.5F);
}
Screen fit for the GridView subkey, child item width, height and width
Itemwidth = (Getscreenwidth (this)-(3*DIPTOPX (this, 3))/2;
To set the parameters of a subkey in the GetView in the adapter of the GridView
Public View GetView (int position, View Convertview, ViewGroup parent) {
Viewhodler viewhodler;
String url = blogalbumlist.get (position). Getalbumurl ();
if (Convertview = = null) {
Convertview = view.inflate (context, r.layout.celebrity_item, null);
Viewhodler = new Viewhodler ();
Viewhodler.iv_image = (ImageView) Convertview.findviewbyid (r.id.iv_image);
Convertview.settag (Viewhodler);
} else {
Viewhodler = (viewhodler) convertview.gettag ();
}
if (ViewHodler.iv_image.getTag ()!=url | | ViewHodler.iv_image.getTag () ==null) {
imagetools.getimageloader (). DisplayImage (Blogalbumlist.get (position) . Getalbumurl (), Viewhodler.iv_image, mdisplayimageoptions);
ViewHodler.iv_image.setTag (URL);
}
abslistview.layoutparams param = new Abslistview.layoutparams (Leoapplication.itemwidth, Leoapplication.itemwidth);
Convertview.setlayoutparams (param);
return convertview;
}
In fact, the GridView has an attribute. android:stretchmode= "columnWidth"//Zoom and column width size sync
Some special properties of the GridView:
1.android:numcolumns= the number of columns in the "Auto_fit"//gridview is set to Automatic
2.android:columnwidth= "90DP"//The width of each column, which is the width of the item
3.android:stretchmode= "columnWidth"//Zoom sync with column width size
4.android:verticalspacing= "10DP"//two margins between lines
5.android:horizontalspacing= the margin between the "10DP"//Two columns
6.android:cachecolorhint= "#00000000"//Remove the default black background when dragging
7.android:listselector= "#00000000"//Remove yellow background When selected
8.android:scrollbars= ' None '//Hide the GridView scroll bar
9.android:fadescrollbars= "true"//set to True to enable automatic hiding and display of scroll bars
10.android:fastscrollenabled= ' true '//gridview a fast-scrolling button (at least 4 pages are not displayed)
11.android:fadingedge= "None"//gridview fading (Fade) edge color is NULL, the default value is vertical. (can be interpreted as a hint color for the top and bottom edges)
12.android:fadingedgelength= "10dip"//Definition of fading (fade) edge length
13.android:stackfrombottom= "true"//set to True, the list that you do well will display the bottom of your list
14.android:transcriptmode= "Alwaysscroll"///When you add data dynamically, the list will automatically scroll down the latest entries can automatically scroll to the visual range
15.android:drawselectorontop= "false"//click on a record, the color will be the background color after the record, the text of the content is visible (default is False)