Saturday 15 September 2012

android - Using Gridview and Button in LinearLayout -


I tried to add buttons below the gridview in linerlight on the following code. But when I execute my app, I see only Gridview that there are no button items. So this may be a basic mistake, but I can not see it.

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: orientation = "horizontal" Android: background = "# 2 A2A2A "& gt; & Lt; Android: layout_height = "wrap_content" android: columnWidth = "150dp" Android: numColumns = "auto_fit" Android: horizontalSpacing = "10dp" Android: verticalSpacing: GridView Android: id = = "10dp" Android: stretchMode = "columnWidth" Android: gravity = "center" & gt; & Lt; / GridView & gt; & Lt; Button Android: id = "@ + id / Button1" Android: layout_width = "wrap_content" android: layout_height = "50dp" Android: text = "@ string / cam_string" /> & Lt; / LinearLayout & gt;    

After "text" itemprop = "text">

to your LinearLayout orientation Change vertical . I suspect you are not seeing the button because the gridview takes all the horizontal space, then the linear layout adds the button to a place that is not visible. You can also change the "0dip" to layout_height GridView and it may` want to give Android. So that it will fill all the space except by the button that took the layout_weight = 1 'attribute

No comments:

Post a Comment