I placed an image in each ListView Item at the right side,In the layout xml,I set its width and length as 20dip ,kind of small,and I find it is hard to click at it cause the image only occupied 20*20 dip,I hope the length of it doesn't change,while its height full filling the parent, I tried :
android:layout_width="20dip"
android:layout_height="fill_parent"
but it doesn't work.
Below is my 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>
If you have carefully watch the twitter client for Android,you will find that the image at right side of each ListView Item is quite easy to click (even you have not click on the image but say for example on top of the button). I want to know how to do that.
twitter image 开发者_开发知识库http://www.freeimagehosting.net/uploads/889d10c435.png
Any one? any help?
Is it possible that the twitter image is actually larger than the circle with the triangle? Try padding the image with a larger transparent background.
EDIT: This is an old question, but I'm cleaning up my answer nonetheless. I'm not certain that creating a transparent image (or UI element) is the best solution here, but it seems like a plausible one.
This question is related to creating a transparent ListView (How To Make a Listview Transparent in Android). The answers suggest editing the styles.xml file to include something along the lines of the following code (taken from Jacky's answer).
android:background="@drawable/bg"
android:cacheColorHint="#00000000"
Similarly, this post covers implementing transparent activities (How to Create Transparent Activity in Android). The code from the accepted answer follows.
<?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>
Finally, here's a general question on image opacity/transparency in Android (Android: Make image opaque/transparent). The accepted answer suggests using the following code in order to draw transparent shapes:
Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
buffer.eraseColor(Color.TRANSPARENT);
精彩评论