gpt4 book ai didi

android - 如何更改操作栏选项卡中的选项卡背景颜色

转载 作者:行者123 更新时间:2023-11-29 17:36:21 28 4
gpt4 key购买 nike

我正在实现带有操作栏的选项卡但我无法更改选项卡的背景颜色谁能帮帮我。

提前致谢。

我的输出

enter image description here

我需要的输出

enter image description here

对于我使用下面代码的底部条纹红色

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- STATES WHEN BUTTON IS NOT PRESSED -->

<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="false"
android:drawable="@color/transparent" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_example" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected_focused_example" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_focused_example" />


<!-- STATES WHEN BUTTON IS PRESSED -->

<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed_example" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed_example" />

</selector>

将资本改为小 Text appear all caps in Action Bar Tabs in Sherlock

<style name="My.TabText.Style" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">normal</item>
</style>

更改操作颜色和标签颜色

// set background for action bar
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0c2354")));

// set background for action bar tab
bar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#B5C0D0")));

最佳答案

试试这个。

                 for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#01afeb")); // unselected
TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
tv.setTypeface(Typeface.MONOSPACE);
//Unselected Tabs
tv.setTextColor(Color.parseColor("#ffffff"));
}

mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#f9b526")); // selected
TextView tv = (TextView) mTabHost.getCurrentTabView().findViewById(android.R.id.title); //for Selected Tab

tv.setTextColor(Color.parseColor("#01afeb"));

关于android - 如何更改操作栏选项卡中的选项卡背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30376578/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com