Making a widget look like a regular homescreen icon

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Making a widget look like a regular homescreen icon

Postby Sprucie » Wed Nov 04, 2009 5:52 am

I'm trying (and failing) to create a widget that displays text below it so that it looks like a regular old homescreen icon. To clarify, the text below regular homescreen icons is white text on top of a dark rectangle that has pretty rounded edges. See this screenshot: http://screencast.com/t/NWJ509s98T

Is there a way to give a widget that same kind of text?

Thanks!
Sprucie
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 04, 2009 5:11 am

Top

Postby padde » Wed Nov 04, 2009 11:06 am

Well its not perfect.. but really close i think.
I hope you will get the idea.

1. the widget layout
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:layout_width="fill_parent"
  7.  
  8.    android:layout_height="fill_parent"
  9.  
  10.    android:gravity="bottom"
  11.  
  12.    android:orientation="vertical">
  13.  
  14.  
  15.  
  16.     <ImageView
  17.  
  18.        android:layout_width="wrap_content"
  19.  
  20.        android:layout_height="wrap_content"
  21.  
  22.        android:layout_gravity="center_horizontal"
  23.  
  24.        android:src="@drawable/icon"/>
  25.  
  26.        
  27.  
  28.     <TextView
  29.  
  30.        android:layout_width="wrap_content"
  31.  
  32.        android:layout_height="wrap_content"
  33.  
  34.        android:text="Browser"
  35.  
  36.        android:textColor="#ffffffff"
  37.  
  38.        android:textSize="13px"
  39.  
  40.        android:layout_marginTop="2px"
  41.  
  42.        android:layout_marginBottom="6px"
  43.  
  44.        android:layout_gravity="center_horizontal"
  45.  
  46.        android:background="@drawable/icon_text"/>
  47.  
  48. </LinearLayout>
  49.  
  50.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


2. widget size should be 72dp x 72dp

3. the images i used (last 2).. place them in res/drawable
Attachments
device.png
result
device.png (83.96 KiB) Viewed 217 times
icon_text.9.png
icon_text.9.png (219 Bytes) Viewed 217 times
icon.png
icon.png (3.11 KiB) Viewed 217 times
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby Sprucie » Wed Nov 04, 2009 10:27 pm

Padde, thanks. That is certainly very close. However, that ninepatch that Android is using must surely be available somewhere, right? I searched the SDK directory for *.9.png and found many promising-looking images, but nothing that was quite the right one. And yet it surely must be attainable.

Thanks!
Sprucie
Freshman
Freshman
 
Posts: 5
Joined: Wed Nov 04, 2009 5:11 am

Postby padde » Wed Nov 04, 2009 11:28 pm

I looked at every png of the android.jar and found nothing that fits.
My guess is its build dynamic because it seems to change color depending
on the darkness of the background.. you can see that on the screenshot
i provided.. the text background in the first row is lighter.. in the last row
its black or almost black. So my guess is its somekind of generated by the
system and there isnt any fixed gfx for it.
Actually why does the widget have to look exactly like a normal icon and
almost isnt good enough? :)
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests