Home » Android » Android Widget looking exactly like a Launcher Icon

Android Widget looking exactly like a Launcher Icon

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am having a hard time with widgets. Reading from http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#cellstable there is the following table:

  • 1 cell – 40dp
  • 2 cell – 110dp
  • n cell – 70 × n − 30 dp

So my widget that wants to look as a launcher its gonna have minHeigth and minWidth as 40dp. So far what I did is use icons as launcher, 192px, 144px, 96px, 72px and 48px.

But I can’t get the exact feeling as an icon launcher (text style, touching style…). I can try to guess but… Is somewhere out there the source code for the launcher layout? I can’t find it. See how it looks like the widget in comparing to other icons:

enter image description here

Another thing I wanted to try is to make that green icon to fill all the cell (as a background) and then another image and the text inside. I can’t get that to look good either and I wonder if the only way is to use 9patch images here…

So far that’s my widget layout code:

<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <ImageView
    android:id="@+id/appwidget_button"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_gravity="center_horizontal"
    android:layout_weight="1"
    android:src="@drawable/widget_1_background"/>

  <TextView
    android:id="@+id/appwidget_text"
    android:typeface="sans"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:textColor="@android:color/white"
    android:textSize="12sp"
    android:singleLine="true"/>

</LinearLayout>

Suggestions?

How to&Answers: