先看代码:textView.setLayoutParams(new TextSwitcher.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 为什么要用TextSwitcher的LayoutParams呢。查一查API,可以看到这么一句话These supply parameters to the parent of this view specifying how it should be arranged。 也就是说一定要用父控件的LayoutParams。如果父控件是LinearLayout,当然就必须写成LinearLayout.LayoutParams
LayoutParams有多个控件的类,要引用哪个类关键是要看父控件是什么样的view控件.
setLayoutParams
最新推荐文章于 2022-10-17 15:02:29 发布
本文探讨了在Android开发中为何需要使用TextSwitcher的LayoutParams,并解释了LayoutParams的选择需依据父控件类型来确定。
3168

被折叠的 条评论
为什么被折叠?



