Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make a home widget behave like a launcher icon?
    text
    copied!<p>I have a widget that acts as a launcher on the home screen. How can I make it behave like a launcher icon?</p> <p>I use this layout for portrait:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;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"&gt; &lt;ImageView android:id="@android:id/background" android:layout_width="72dip" android:layout_height="72dip" android:layout_marginLeft="1dip" android:layout_marginTop="4dip" /&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And this is the background selector:</p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/widget_background_pressed" /&gt; &lt;item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/widget_background_focused" /&gt; &lt;item android:state_window_focused="false" android:state_focused="true" android:drawable="@android:color/transparent" /&gt; &lt;/selector&gt; </code></pre> <p>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.</p> <p>Any idea what I do wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload