찾다

 >  Q&A  >  본문

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일 전690

모든 응답(1)나는 대답할 것이다

  • PHP中文网

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

    ivYellowButterflyivBlueButterflysetLayoutParams()로 설정하거나 ivYellowButterflyivYellowButterflyLayoutParams으로 설정해야 합니다.

    회신하다
    0
  • 취소회신하다