我正在创建线性布局编程,并希望他们淡入淡出时,可见性设置为可见/消失。
我可以设置
android:animateLayoutChanges="true"
但是因为我是以编程方式创建视图的,所以需要以编程方式设置它。我该怎么做?
Use this code:
container.setLayoutTransition(new LayoutTransition());
or
LayoutTransition lt = new LayoutTransition(); lt.disableTransitionType(LayoutTransition.DISAPPEARING); container.setLayoutTransition(lt);
To disable the fade-out effect try this:
LinearLayout layout = (LinearLayout) findViewById(R.id.test_layout); layout.setLayoutTransition(null);