android - How to Set image size in grid view -
There is a grid view with 3 columns wrapped in my relative layout. At present, the view of a large device (7 inch tablet) looks small, so I want to increase the size of images according to the screen size.
My getView () in baseApdter for Gridview: and my XML with grid view: ImageView.setLayoutparams throws trying to use (...) java.lang.ClassCastException: android.widget.RelativeLayout $ LayoutParams can not be molded android. widget.LinearLayout $ LayoutParams The exception was due to your code: : Because you were using LinearLayout in Layout_appinfo.xml when you set the laser param for an object, then it depends on the original layout type.
& lt; Relative layout xmlns: android = "http://schemas.android.com/apk/res/Android" xmlns: Tools = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: layout_height = "Match_parent" Android: background = "@ drawable / background" device: reference = ". Main" & gt; & Lt; Android: layout_height = "fill_parent" Android: columnWidth = "200dip" Android: Gravity = "Center" Android: horizontalSpacing = "40dip" Android: numColumns: GridView Android: ID = "@ + id / gvMain" Android: layout_width = "fill_parent" = "3" android: padding = "10dip" Android: stretchMode = "columnWidth" Android: verticalSpacing = "10dip" /> & Lt; Android: layout_alignParentRight = "True" Android: layout_alignParentRight = "true" Android: paddingRight = "10dp" Android: paddingBottom: Android: layout_width = "45dp" Android: layout_height = "45dp" Android: layout_alignParentBottom = "true" Android: id = "@ + id / btn_facebook" = "10dp" Android: background = "@drawable / FB_button" /> & Lt; / RelativeLayout & gt;
ivIcon.setLayoutParams (New Responsive Layout. LayoutParams (85, 85)); Change to
ivIcon.setLayoutParams (new LinearLayout.LayoutParams (85, 85));
Comments
Post a Comment