search

Home  >  Q&A  >  body text

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);
天蓬老师天蓬老师2802 days ago686

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:24:59

    You should set ivYellowButterflyivBlueButterflysetLayoutParams()或者获取ivYellowButterflyivYellowButterflyLayoutParams to set it up.

    reply
    0
  • Cancelreply