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