0
我用来有一个相对布局,我用一些ImageButtons排列。现在,因为我有很多按钮,我虽然会减少代码大小,并动态地使用java代替静态xml中的大部分内容。我创建了一个网格布局,其中将元素ImageButtons与TextView一起引入。Android图像按钮奇怪的行为
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="50" >
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
<ImageButton
android:id="@+id/button_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view"
android:layout_centerHorizontal="true"
android:src="@drawable/play_button" />
</RelativeLayout>
我扩展BaseAdapter并传递一个列表项来填充gridview。它的工作原理确定,但使用的按钮看起来不同(背景颜色):
另外,WRAP_CONTENT属性是有点过了,因为它切断有点边缘的底部和右侧。 任何想法可能导致这种情况?
使用ImageView如果你没有任何文字it.it可能会解决你的问题。 – Manmohan
使用ImageView设置'android:scaleType'为'ImageButton' –
@Manmohan避免了这个问题,我想知道为什么会发生这种情况..!但如果我找不到为什么我会恢复到这个选项。 – tk66