I have a widget that acts as a launcher on the home screen. How can I make it behave like a launcher icon?
I use this layout for portrait:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:background="@drawable/widget_background_selector"
android:focusable="true"
android:layout_width="74dip"
android:layout_height="79dip"
android:layout_marginLeft="3dip"
android:layout_marginTop="14dip">
<ImageView android:id="@android:id/background"
android:layout_width="72dip"
android:layout_height="72dip"
android:layout_marginLeft="1dip"
android:layout_marginTop="4dip" />
</RelativeLayout>
</RelativeLayout>
And this is the background selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/widget_background_pressed" />
<item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/widget_background_focused" />
<item android:state_window_focused="false" android:state_focused="true" android:drawable="@android:color/transparent" />
</selector>
This way if I use the DPAD the widget is focusable but the click doesn't work. The touch still works but the widget is not displayed as focused.
Any idea what I do wrong?