先看一下代码
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