开发者

Android App UI tab... is this UI possible?

开发者 https://www.devze.com 2023-02-22 23:46 出处:网络
How c开发者_运维技巧an i implement this in a TabActivity? That looks much like the standard TabHost ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html ) and an implementati

How c开发者_运维技巧an i implement this in a TabActivity?

Android App UI tab... is this UI possible?


That looks much like the standard TabHost ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html ) and an implementation of OnTabChangedListener.

Add the listener to the instance of your TabHost:

tabHost.setOnTabChangedListener(new OnTabChangeListener(){
    @Override
    public void onTabChanged(String tabId) {
        setTabHostColors();
    }});

Handle changing the background color:

private void setTabHostColors() {
    for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) {
        tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.rgb(0, 0, 0)); //unselected
    }
    tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.rgb(50, 120, 160)); // selected
}

And then finally it obviously has a nice little background picture, not sure where to get that one I'm afraid.


Here is a small sample project to customize your tabs: http://code.google.com/p/android-custom-tabs/

0

精彩评论

暂无评论...
验证码 换一张
取 消