我正在使用下面的代碼來使用remoteview在窗口小部件imageview上設置圖像,現在我想設置圖像視圖運行時的高度和寬度。以編程方式在窗口小部件上設置ImageView寬度和高度
if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetActivity1_1.this);
RemoteViews remoteViews = new RemoteViews(WidgetActivity1_1.this.getPackageName(), R.layout.widget_layout1_1);
Intent configIntent = new Intent(WidgetActivity1_1.this,UpdateWidgetService.class);
configIntent.putExtra("Appid", appWidgetId);
PendingIntent configPendingIntent = PendingIntent.getService(WidgetActivity1_1.this, appWidgetId, configIntent, 0);
remoteViews.setImageViewResource(R.id.imgviewGrow, R.drawable.flower1);
}
感謝答覆,但它會改變我使用的ImageView,但構件,因此我們不能直接訪問的ImageView我們必須使用遠程視窗爲u可以在我的崗位看,我現在已經建立圖像運行的ImageView heigth寬度這樣我想在遠程視圖中設置高度寬度。 – PankajAndroid 2013-03-02 07:14:09
查看更新的答案。 – 2013-03-02 07:25:14
當您在widget中設置圖片視圖佈局時,您無法設置它,您必須先向用戶remotivew和遠程觀看者提供setLayoutPrarms方法。 – PankajAndroid 2013-03-02 07:33:23