I have activity with three GrindViews. I fill these views with custom SimpleCursorAdapters. In each cell is button which I need to be stretched into that cell of GrindView. And also I need that there will be no free space between that GrindViews. I already try to set padding/margin with no effect. Here are the XMLs:
MainView:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<GridView android:id="@+id/gridview1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numColumns="5"
android:gravity="center" />
<GridView android:id="@+id/gridview2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numColumns="5"
android:gravity="center" />
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview3" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:numColumns="4"
android:gravity="center" />
Cell:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:padding="1dip"
android:layout_height="fill_parent" android:orientation="horizontal">
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:padding="1dip"
android:layout_height="fill_parent" android:id="@+id/textButton" />
Screenshot:
Current Status
Thanks for any help!
I think you’ll have to set your own drawable image for your buttons, and not use the standard system image. Unless I’m mistaken, the standard MDPI image for buttons has a built in transparent border of 3 pixels on the horizontal sides, 1 pixel on the top side, and 4 pixels on the bottom side. So, even if this button image were fully expanded to 100% fill a grid cell, it would still include this transparent border, and thus not appear to fully fill the cell. (This is based on the assumption that the default button image is btn_default_normal.9.png.)
Instead of using Buttons, take a look at ImageButton, which allows you to set your own image. Or, to use the regular Button, you may need to set the button’s background image with a state list drawable. Take a look at the “Button style” section for more information.
—
However, I do see now in the docs, “Explicitly setting a padding value will override the corresponding padding found in the background.” I see you mentioned you tried setting the padding, but did you try setting the padding to zero?