Good Search

Thursday, April 12, 2012

Discovery about Launcher on Android 4.x (Ice Cream Sandwich) Part2

Launcher part 2 Widget & Hotseat
Framework for Widget

You could setup your widget in AndroidManifest.xml of app.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mywidget.app">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:label="@string/app_name" android:name="com.mywidget.app.WidgetReciver">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="android.appwidget.action.APPWIDGET_DELETED"/>
<action android:name="android.appwidget.action.APPWIDGET_DISABLED"/>
<action android:name="android.appwidget.action.APPWIDGET_ENABLED"/>
</intent-filter>
<meta-data
android:resource="@xml/my_widget_provider" >
</meta-data>
</receiver>
</application>
</manifest> 

And design the look of widget here.

main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal">
<ImageButton
android:id="@+id/Button01"
android:background="@drawable/bloodeye" />
<ImageButton
android:id="@+id/Button02"
android:background="@drawable/bloodeye" />
</LinearLayout>

my_widget_provider.xml
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="110dp"
android:minHeight="110dp"
android:updatePeriodMillis="1000"
android:initialLayout="@layout/main"
/>

Size: The cells of widget


# of Cells Available Size (dp)
1
40dp
2
110dp
3
180dp
4
250dp


Screenshot

Operation Framework of Widget in Launcher: 
how to drag your widget and remove it later.



HotSeat.xml

<com.android.launcher2.Hotseat
       launcher:cellCountX="5"
       launcher:cellCountY="1">
       <com.android.launcher2.CellLayout android:id="@+id/layout"/>
</com.android.launcher2.Hotseat>

Modify the default shortcus fo HotSeat(Red Parts)
Default_workspace.xml
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
<favorite
launcher:packageName="com.android.contacts“
launcher:className="com.android.contacts.activities.DialtactsActivity"
launcher:x="0"
launcher:y="0" />
<favorite
launcher:packageName="com.android.contacts“
launcher:className="com.android.contacts.activities.PeopleActivity"
launcher:x="1"
launcher:y="0" />
<favorite
launcher:packageName="com.android.mms“
launcher:className="com.android.mms.ui.ConversationList"
launcher:x="3"
launcher:y="0" />
<favorite
launcher:packageName="com.android.browser“
launcher:className="com.android.browser.BrowserActivity"
launcher:x="4"
launcher:y="0" />
</favorites>


Drag a widget into another one -> addFolder





Part 2 is over
Thank you for your patient reading

No comments:

Post a Comment