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. 如何在标签上添加动画?
- 2. 更改标签,并添加值
- 3. 将动画添加到图像更改
- 4. [UIView animateWithDuration动画更改后更改标签文本
- 5. 如何将动态更改的浮动值添加到标签
- 6. 将光标更改为加载动画
- 7. JButton不会更改标签并添加新标签
- 8. 用动画更改徽标
- 9. 更改活动标签时router.navigate被
- 10. TableView添加一个自动更改的新标签
- 11. 如何添加滑动以更改标签页
- 12. 我如何在更改路线时为页面添加动画?
- 13. 更改UIScreen亮度时添加动画淡入效果(Swift)
- 14. 标签动画
- 15. 标签更改时UIButton更改宽度
- 16. jQuery Tabs - 当标签加载时更改标签外的内容
- 17. wxribbonbuttonbase动态标签更改
- 18. Highcharts动态更改标签?
- 19. 在转换/状态改变时自动添加标签
- 20. 其他标签更改时如何更改标签?
- 21. 创建新标签时更改select2自动选择的标签
- 22. 如何在动画中的移动圆圈后添加标签?
- 23. 标签时,配置更改
- 24. 更改标签时出错
- 25. 更改textview时的动画
- 26. 更改animationDuration动画时
- 27. 更改ContentTemplate时的动画
- 28. SwipeRefreshLayout - 更改动画时机
- 29. 添加视图到标签Vs添加活动标签android
- 30. 如何更改TabLayout的滑动标签条动画持续时间?
感谢您的回复!问题是我有一个活动标签主机,而不是一个视图标签主机。 – Gratzi 2010-11-02 15:26:52