android-studio - Android 动态壁纸LayoutParams问题
天蓬老师
天蓬老师 2017-04-17 17:22:59
0
1
672

最近在做一个动态壁纸项目,我在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);
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template