我有三个GrindViews的活动。我使用自定义SimpleCursorAdapters填充这些视图。在每个单元格中都是按钮,我需要将其拉伸到GrindView的单元格中。而且我还需要在GrindViews之间没有可用空间。我已经尝试设置填充/边距没有效果。以下是XML:
的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" />
细胞:
<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" />
截图: Current Status
感谢您的帮助!
答案 0 :(得分:0)
我认为您必须为按钮设置自己的可绘制图像,而不是使用标准系统图像。除非我弄错了,按钮的标准MDPI图像在水平边上有3个像素的内置透明边框,顶部有1个像素,底部有4个像素。因此,即使此按钮图像完全展开到100%填充网格单元格,它仍将包含此透明边框,因此看起来不会完全填充单元格。 (这是基于默认按钮图像为btn_default_normal.9.png的假设。)
不要使用按钮,而是查看ImageButton,它允许您设置自己的图像。或者,要使用常规Button,您可能需要使用状态列表drawable设置按钮的背景图像。请查看“按钮样式”部分以获取更多信息。
-
但是,我现在在文档中看到,“显式设置填充值将覆盖后台找到的相应填充。”我看到你提到你试过设置填充,但是你尝试将填充设置为零吗?