I have a widget that acts as a launcher on the main screen. How can I make it behave like a launch icon?
I use this layout for a 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 switch:
<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>
Thus, if I use DPAD, the widget is custom, but the click does not work. The touch still works, but the widget does not appear as focused.
Any idea what I'm doing wrong?
Tughi source
share