4
A
回答
10
嗨
对于这一点,最好的解决办法是动画添加到布局
假设你有两个标签
tabs = (TabHost) this.findViewById(R.id.tabhost_id);
tabs.setup();
tspec1 = tabs.newTabSpec(name_of_1st_tab)
tspec1.setIndicator(....);
tspec1.setContent(R.id.tab_1_layout_id);
tab1Layout = (LinearLayout)findViewById(R.id.tab_1_layout_id);
tspec2 = tabs.newTabSpec(name_of_2nd_tab)
tspec2.setIndicator(....);
tspec2.setContent(R.id.tab_1_layout_id);
tab1Layout = (LinearLayout)findViewByIdR.id.tab_2_layout_id);
然后在TabChangedListener
tabs.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
tab1Layout.setAnimation(outToLeftAnimation());
tab2Layout.setAnimation(inFromRightAnimation());
}
});
public Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(ConstandsUsed.ANIMATIION_DURATION);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
public Animation outToLeftAnimation() {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoLeft.setDuration(ConstandsUsed.ANIMATIION_DURATION);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
希望这将有助于你得到一些想法
0
这可能会帮助你。主要想法是获取选项卡的当前视图并在onTabChanged事件中为其设置动画。
tabsHost.setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
View currentView = tabsHost.getCurrentView();
currentView.setAnimation(<Your animation object goes here>);
}
});
相关问题
- 1. AngularJS:更新div标签时添加动画
- 2. [UIView animateWithDuration动画更改后更改标签文本
- 3. 将光标更改为加载动画
- 4. 用动画更改徽标
- 5. 更改活动标签时router.navigate被
- 6. TableView添加一个自动更改的新标签
- 7. 如何添加滑动以更改标签页
- 8. 更改UIScreen亮度时添加动画淡入效果(Swift)
- 9. 在转换/状态改变时自动添加标签
- 10. wxribbonbuttonbase动态标签更改
- 11. 其他标签更改时如何更改标签?
- 12. 如何在动画中的移动圆圈后添加标签?
- 13. 更改textview时的动画
- 14. 更改animationDuration动画时
- 15. 更改ContentTemplate时的动画
- 16. 如何更改TabLayout的滑动标签条动画持续时间?
- 17. 动态添加标签
- 18. 动态添加标签upgradeElement
- 19. QML动态添加标签
- 20. 更改标签
- 21. 更改标签
- 22. 更改标签
- 23. 更改标签
- 24. 更改动画
- 25. 更改活动标签上的图标
- 26. 当画布/小部件打开时用Tkinter更改标签
- 27. 如何为核心绘图数据标签添加动画?
- 28. 移动span标签动画
- 29. 动态添加uib accordion标头标签
- 30. 添加标签
感谢您的回复!问题是我有一个活动标签主机,而不是一个视图标签主机。 – Gratzi 2010-11-02 15:26:52