android-studio - Android 動態壁紙LayoutParams問題
問題描述
最近在做一個動態壁紙項目,我在Engine的onCreate方法里,去添加兩只“蝴蝶”時,我使用了addView(imageview,new LayoutParams(width,height))方法,但是無論我怎么改變width和height,“蝴蝶”的大小都沒有發生變化。我在網上查了下,貌似方法的使用是沒有問題的,那么我應該怎么去調整imageview 的大小?

這個是效果圖,下面是設置的代碼:
LinearLayout.LayoutParams ivBlueParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); ivBlueParams.gravity= Gravity.CENTER; LinearLayout.LayoutParams ivYellowParams=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); widgetGroup.addView(ivYellowButterfly,ivYellowParams); widgetGroup.addView(ivBlueButterfly,ivBlueParams);
問題解答
回答1:你應該設置ivYellowButterfly與ivBlueButterfly的setLayoutParams()或者獲取ivYellowButterfly與ivYellowButterfly的LayoutParams進行設置。
相關文章:
1. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””2. boot2docker無法啟動3. docker-compose中volumes的問題4. nignx - docker內nginx 80端口被占用5. java - SSH框架中寫分頁時service層中不能注入分頁類6. docker安裝后出現Cannot connect to the Docker daemon.7. dockerfile - 為什么docker容器啟動不了?8. docker容器呢SSH為什么連不通呢?9. 關于docker下的nginx壓力測試10. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?

網公網安備