Android 如何使图像更易于单击?
我在右侧的每个ListView项目中放置了一个图像,在布局xml中,我将其宽度和长度设置为20dip,有点小,我发现很难单击它,因为图像只占用了20*20 dip,我希望它的长度不会改变,而它的高度完全填充了父对象, 我试过:Android 如何使图像更易于单击?,android,layout,imageview,Android,Layout,Imageview,我在右侧的每个ListView项目中放置了一个图像,在布局xml中,我将其宽度和长度设置为20dip,有点小,我发现很难单击它,因为图像只占用了20*20 dip,我希望它的长度不会改变,而它的高度完全填充了父对象, 我试过: android:layout_width="20dip" android:layout_height="fill_parent" 但它不起作用 下面是我的xml: <RelativeLayout xmlns:android="http://sche
android:layout_width="20dip"
android:layout_height="fill_parent"
但它不起作用
下面是我的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="6dip"
android:background="#FFFFFF">
<ImageView android:id="@+id/avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"
android:src="@drawable/default_happy_face" />
<RelativeLayout
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/avatar"
android:layout_toLeftOf="@+id/optionImg">
<!-- some stuff unrelated-->
</RelativeLayout>
<!-- v Pay attention here v -->
<ImageView android:id="@+id/optionImg"
android:layout_width="20dip"
android:layout_height="fill_parent"
android:layout_marginLeft="15dip"
android:paddingLeft="5dip"
android:adjustViewBounds="true"
android:background="@drawable/option_normal"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
如果你仔细观察了Android版的twitter客户端,你会发现每个ListView项目右侧的图像都很容易点击(即使你没有点击图像,比如说在按钮顶部)。我想知道怎么做
有人吗?有什么帮助吗 推特图像是否可能比带三角形的圆圈大?尝试用更大的透明背景填充图像。编辑:这是一个老问题,但我正在整理我的答案。我不确定创建透明图像(或UI元素)是否是这里的最佳解决方案,但这似乎是一个合理的解决方案 这个问题与创建透明的ListView()有关。答案建议编辑styles.xml文件,使其包含以下代码(摘自Jacky的答案) 类似地,本文介绍了如何实现透明活动()。接受答案的代码如下
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
不,实际上我直接使用了twitter上的图片(我解压了apk,得到了图片),它和它看起来一样大,我想知道他们可能已经把ImageView的长度填满了父视图,所以,【ImageView】比它里面的【image】大,虽然我试过了,但仍然不知道怎么做。知道吗?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
buffer.eraseColor(Color.TRANSPARENT);