我一直试图制作一个看起来像这样的tabstyle.但到目前为止它不起作用
有人可以帮我弄这个吗..
http://www.technobuzz.net/wp-content/uploads/2010/02/seesmic-android-260-208.png
样式仅显示颜色选中时.当我使用白色图标时,文本(文本setindicator)为白色.这也适用于灰色图标.
当图标颜色为白色时,setindicator中的文本也是白色..我该如何解决这个问题.
提前致谢!
Main.java
intent = new Intent().setClass(this, Settings.class); spec = tabHost.newTabSpec("settings").setIndicator("Settings", res.getDrawable(R.drawable.tab_settings)) .setContent(intent); tabHost.addTab(spec); TabWidget tw = getTabWidget(); for (int i = 0; i < tw.getChildCount(); i++) { VIEw v = tw.getChildAt(i); v.setBackgroundDrawable(getResources().getDrawable (R.drawable.custom_tab)); }
tab_settings
<selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <!-- pressed TAB --> <item androID:state_pressed="true" androID:drawable="@drawable/artists_on" androID:color="#bfbfbf" /> <!-- INACTIVE TABS --> <item androID:state_selected="false" androID:state_focused="false" androID:state_pressed="false" androID:drawable="@drawable/artists_of" /> <!-- ACTIVE TAB --> <item androID:state_selected="true" androID:state_focused="false" androID:state_pressed="false" androID:drawable="@drawable/artists_of" /> <!-- SELECTED TAB --> <item androID:state_focused="true" androID:state_selected="true" androID:state_pressed="false" androID:drawable="@drawable/artists_on" />
custom_tab.xml选项卡样式…
<item androID:state_pressed="true" > <shape> <gradIEnt androID:startcolor="#ea9d32" androID:endcolor="#ffcc50" androID:angle="270" /> </shape></item><!-- WHEN SELECTED --> <!-- HOW CAN I SAID WHEN NOT SELECTED? --> <item androID:state_focused="true" > <shape> <gradIEnt androID:endcolor="#ffcc50" androID:startcolor="#ffcc50" androID:angle="270" /> </shape> </item> <item androID:state_focused="false" > <shape> <gradIEnt androID:endcolor="#ffffff" androID:startcolor="#AAAAAA" androID:angle="270" /> <stroke androID:wIDth="1px" androID:color="#000000" /> </shape> </item></selector>
解决方法:
选项卡背景有四种状态 – 几乎所有这些状态:
<selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <item <!-- pressed TAB --> androID:state_pressed="true" androID:drawable="@drawable/minitab_pressed" /> <item <!-- INACTIVE TABS --> androID:state_selected="false" androID:state_focused="false" androID:state_pressed="false" androID:drawable="@drawable/minitab_unselected" /> <item <!-- ACTIVE TAB --> androID:state_selected="true" androID:state_focused="false" androID:state_pressed="false" androID:drawable="@drawable/minitab_default" /> <item <!-- SELECTED TAB --> androID:state_focused="true" androID:state_selected="true" androID:state_pressed="false" androID:drawable="@drawable/minitab_selected" /></selector>
对于文本颜色,您还需要创建一个选择器并将此drawable指定为textcolor:
<selector xmlns:androID="http://schemas.androID.com/apk/res/androID"> <item androID:state_selected="true" androID:color="@color/white" /> <item androID:state_focused="true" androID:color="@color/white" /> <item androID:state_pressed="true" androID:color="@color/white" /> <item androID:color="#bfbfbf" /></selector>
总结 以上是内存溢出为你收集整理的Android:Tabstyle全部内容,希望文章能够帮你解决Android:Tabstyle所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)