在我的手機上安裝(也發生在仿真器上)後,Widget只有1x1個單元。爲Android創建簡單的小部件。爲什麼widget總是1x1單元大?
我已經嘗試完全卸載應用程序,然後再次安裝它,但創建它的實例時,該小部件仍然只有1x1大小。
任何想法?
這裏是我的供應商信息的XML文件(callernator_widget_provider_info.xml):
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android">
android:minWidth="294dp"
android:minHeight="294dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/widgetmain"
</appwidget-provider>
這裏是佈局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Bertus van Zyl" />
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:text="Button" />
</LinearLayout>
這裏是我的清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.callernator"
android:versionCode="1"
android:versionName="1.0">
<uses-permission
android:name="android.permission.READ_CONTACTS">
</uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".CallernatorWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/callernator_widget_provider_info" />
</receiver>
<activity android:name=".CallernatorActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
謝謝你的迴應。我已經實施了這些更改,並更新了操作步驟以反映它們。該小部件的尺寸仍然只有1x1。我卸載了安裝的版本,重新啓動了手機,並再次安裝以確保沒有舊的設置或其他東西在浮動。 – 2012-04-09 14:40:23