Draw a frame around tap zone on the widget
I have a widget and I want to draw an orange frame around a tap zone on the widget. The frame should appear when a user tapped on the tap zone and disapper when the user releases his/her finger.
At this time I'm using separate layouts for each tap zone. Them works fine except the frame. I guess, I need to set
android:click开发者_JAVA技巧able="true"
android:focuseable="true"
for each layout. Also, I prepared a transparent shape drawable with orange border. But I can't find out what should I do next. How to draw the shape on the tap zone only while it's tapped?
I found the answer on my question here. I have no enough reputation to vote for abscondment's answer. So, could someone please to vote at his post? As about this question,
android:clickable="true"
android:focuseable="true"
attributes are not needed. I simple created a drawable:
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="@android:color/transparent" />
<stroke
android:width="2dp"
android:color="#eeffd700"
/>
</shape>
</item>
</selector>
and set the drawable as a background to my tap zones, like this:
<LinearLayout
android:background="@drawable/selection_rectangle"
/>
精彩评论