Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Gridview and Button in LinearLayout

I tried add button below gridview in linearlayout at following code. But when i execute my app i only see gridview there is no button item. So it may basic mistake but i can't see it.

<?xml version="1.0" encoding="utf-8"?>
    <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="#2a2a2a"
         >
            <GridView 
                    android:id="@+id/grid_view"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:columnWidth="150dp"
                    android:numColumns="auto_fit"
                    android:horizontalSpacing="10dp"
                    android:verticalSpacing="10dp"
                    android:stretchMode="columnWidth"
                    android:gravity="center"></GridView>
            <Button 
                    android:id="@+id/button1" 
                    android:layout_width="wrap_content" 
                    android:layout_height="50dp" 
                    android:text="@string/cam_string" />

    </LinearLayout>
like image 877
cyildirim Avatar asked Mar 26 '26 10:03

cyildirim


1 Answers

Change the orientation of your LinearLayout to vertical. I suspect you're not seeing the Button because the GridView takes up all horizontal space, then the LinearLayout adds the Button in a place off the screen that's not visible. You also may want to change the layout_height of the GridView to "0dip" and give it the `android:layout_weight=1' attribute so that it will fill all space except that taken up by the Button.

like image 92
MattDavis Avatar answered Mar 28 '26 00:03

MattDavis