Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly set a big widget icon in android

This is my question: My program have 2 widgets. One of them is 4x1 cells size. This widget has an icon(has the same width as widget itself) set in manifest file

android:icon="@drawable/widget_4bg"

My problem is that on android OS 4.x mobiles in the widget list, the icon is not spread on entire 4 cells but only in one.

enter image description here

How can I set correctly icon programmatically?

like image 650
Alex Avatar asked Dec 08 '12 14:12

Alex


People also ask

How do I change the size of my widgets on Android?

You can customize your widget's height and width by tapping and holding your finger on the widget to bring up the widget resize mode.

Can you make custom widgets on Android?

You can import and create your own custom widgets for the Android platform. Quantum Visualizerplatform has defined a contract that any custom widget should implement.


1 Answers

Try using this.

android:previewImage="@drawable/widget_4bg"

sample xml widget_info

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/your_widget_layout"
    android:minHeight="400dip"
    android:minResizeHeight="250dip"
    android:minResizeWidth="300dip"
    android:minWidth="450dip"
    android:previewImage="@drawable/widget_preview"
    android:resizeMode="horizontal|vertical"
    android:updatePeriodMillis="172800000" >

</appwidget-provider>

Update

 <receiver
            android:name="com..widget.WidgetProvider"
            >
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />

            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>
like image 73
Ali Imran Avatar answered Nov 05 '22 08:11

Ali Imran