我想修改以下选项卡的文本颜色:(ACCUEIL 和 A LA UNE)(现在为黑色)。
我不知道该怎么做。
这是 FragmentActivity 的代码:
package com.app.myapp.MainFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import com.app.myapp.R;
import com.app.myapp.activities.Recherche_act;
public class TabMainFragment extends FragmentActivity implements ActionBar.TabListener {
private ViewPager viewPager;
private TabMainFragmentAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "ACCUEIL", "A LA UNE" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Typeface parade = Typeface.createFromAsset(getAssets(), "fonts/parade.ttf");
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.actionbar);
TextView title = (TextView) findViewById(R.id.action_bar_title);
title.setTypeface(parade);
title.setTextSize(23);
title.setGravity(Gravity.CENTER_VERTICAL);
title.setTextColor(Color.WHITE);
setContentView(R.layout.main_tab_detail_frag);
//Typeface robotolight = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#E64260")));
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabMainFragmentAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
}
/**
* on swiping the viewpager make respective tab selected
* */
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// on changing the page
// make respected tab selected
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_choix_categorie:
Intent myIntent = new Intent(TabMainFragment.this, Recherche_act.class);
TabMainFragment.this.startActivity(myIntent);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
这是我的 AndroidManifest 的摘录:
<activity android:name="com.app.frisbeee.MainFragment.TabMainFragment"
android:theme="@style/Theme.Rosenormal" />
最后,我的 style.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="Theme.Rosenormal" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_rosenormal</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Rosenormal</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Rosenormal</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Rosenormal</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Rosenormal</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Rosenormal</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_rosenormal</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_rosenormal</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Rosenormal</item>
</style>
<style name="ActionBar.Solid.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_rosenormal</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_rosenormal</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_rosenormal</item>
<item name="android:progressBarStyle">@style/ProgressBar.Rosenormal</item>
</style>
<style name="ActionBar.Transparent.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@drawable/ab_transparent_rosenormal</item>
<item name="android:progressBarStyle">@style/ProgressBar.Rosenormal</item>
</style>
<style name="PopupMenu.Rosenormal" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_rosenormal</item>
</style>
<style name="DropDownListView.Rosenormal" parent="@android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_rosenormal</item>
</style>
<style name="ActionBarTabStyle.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_rosenormal</item>
</style>
<style name="DropDownNav.Rosenormal" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_background_ab_rosenormal</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_rosenormal</item>
<item name="android:dropDownSelector">@drawable/selectable_background_rosenormal</item>
</style>
<style name="ProgressBar.Rosenormal" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_rosenormal</item>
</style>
<style name="ActionButton.CloseMode.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_rosenormal</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Rosenormal.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Rosenormal</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Rosenormal</item>
</style>
</resources>
最佳答案
为此,您需要在自定义主题中覆盖 android:actionBarTabTextStyle。例如:
<style name="Theme.Rosenormal" parent="@android:style/Theme.Holo.Light">
... same as before ...
<item name="android:actionBarTabTextStyle">@style/ActionBarTabText.Rosenormal</item>
</style>
然后:
<style name="ActionBarTabText.Rosenormal" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
<item name="android:textColor">#f00</item>
</style>
您可能想要使用颜色资源,#f00 值只是一个示例。
关于安卓 : Change text color of Tab in FragmentActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24466237/
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
快捷目录前言一、涉及到的相关技术简介二、具体实现过程及踩坑杂谈1.安卓手机改造成linux系统实现方案2.改造后的手机Linux中软件的安装3.手机Linux中安装MySQL5.7踩坑实录4.手机Linux中安装软件的正确方法三、Linux服务器部署前后端分离项目流程1.前提准备(安装必要软件,搭建环境):2.前后端分离项目的详细部署过程:总结前言总体概述:本篇文章隶属于“手机改造服务器部署前后端分离项目”系列专栏,该专栏将分多个板块,每个板块独立成篇来详细记录:手机(安卓)改造成个人服务器(Linux)、Linux中安装软件、配置开发环境、部署JAVA+VUE+MySQL5.7前后端分离项目
在微信小程序开发中遇到在video组件的两个问题1.安卓手机里播放视频会有明显的卡顿问题刚开始以为是网络问题,或者是视频文件问题。排查了一下发现都没问题最后加了个属性就OK了uniapp和原生小程序方法:custom-cache="false"custom-cache={{false}}video组件兼容iOS手机custom-cache加了这个属性会让2.iOS手机第一次播放视频会有几秒黑屏问题因此我加了当前手机型号的判断uni.getDeviceInfo().deviceType获取当前设备api当为iPhone时不加custom-cache属性,否则加上custom-cache=“fal
安卓渐变的背景框实现1.背景实现方法1.利用PorterDuffXfermode进行图层的混合,这是最推荐的方法,也是最有效的。2.利用canvas裁剪实现,这个方法有个缺陷,就是圆角会出现毛边,也就是锯齿。3.利用layer绘制边框1.背景万恶的设计小姐姐又来搞事情啦,你说好好的设计一个纯色的背景框框不好嘛,非要把一个框框弄成渐变的,如果不拿出放大镜估计没几个人能看出来它是渐变的。来,我让你看看是啥样框子是从左到右渐变的,设计应该是做了一个底图,然后上面盖了一个白色圆角矩形。那么我们该怎么去实现它呢?实现方法下面介绍三种实现它的方法。先贴上源码地址,大家记得给个starhttps://git
简介:有时我们需要调试手机浏览器网页信息,这时除了使用fiddler抓包拦截篡改,还可以通过USB连接,通过PC远程调试手机上的浏览器信息,进行映射。历史攻略:adb:安卓手机USB调试模式前置准备:网页内容在移动设备上的体验可能和电脑上完全不同。ChromeDevTools提供远程调试功能安卓远程调试支持:在浏览器选项卡中调试网站。在原生安卓应用中调试网页内容。将屏幕从你的安卓设备上投影到你的开发机器上。使用端口转发和虚拟主机映射来让安卓设备访问开发使用的服务器。操作步骤:1、手机通过USB连接电脑。2、开启手机调试模式。3、PC电脑edge输入:edge://inspect/#device
Java对象生命周期:创建:为对象分配内存空间,构造对象应用:此时对象至少被一个强引用持有不可见:未被任何强引用持有,进行可达性分析不可达:可达性分析为不可达,进入下一阶段收集:当垃圾回收器发现该对象已经处于“不可达阶段”并且垃圾回收器已经对该对象的内存空间重新分配做好准备时,则对象进入了“收集阶段”。如果该对象已经重写了finalize()方法,则会去执行该方法的终端操作。终结:当对象执行完finalize()方法后仍然处于不可达状态时(可达性分析垃圾回收算法被回收前,会有两次标记过程,判断是否执行lfinalize()方法,执行完之后判断是否GCROOT可达,如果仍不可达,则准备回收),则
最近换了工作,新工作是负责用qml做qt安卓开发。工作中遇到一个问题:安卓设备有USB口,需要插入一个U盘在程序里读写U盘中的文件,由于安卓系统的安全性的问题导致QFile、c++的文件操作相关方法都不能读写成功,想要读写成功只能调用java代码,在java代码里面使用安卓的DocumentFile库。经过一番探索,成功解决了问题。qt如何添加java代码不说了,网上有。下面是具体的java代码:packagecom.example.myapplication;importandroid.annotation.TargetApi;importandroid.content.Context;im
Obsidian安卓端同步及使用(RemotelySave+阿里云同步S3)强烈推荐的obsidian的markdown教程obsidian这款软件很不错,最近刚入门,用来做笔记,喜欢在电脑上做笔记,手机端能随时查看,故捣鼓了一下安卓端的同步及安卓端的使用1.安装包获取不能科学上网,我是到官方中文论坛上找到的,网址如下:移动端v1.4.1开始测试-Obsidian中文论坛2.电脑端同步+阿里云配置我使用的是RemotelySave插件首先,电脑端关闭安全模式,下载这个第三方插件,登不上的看这里,网址如下:完美解决obsidian无法加载第三方插件(社区插件)的问题然后就是阿里云的同步
我知道这里有一百个问题和我一样,但似乎没有一个适合我的具体问题,所以我要问一个新问题。以防万一这是重复,我很抱歉。所以,我正在构建一个应用程序,布局给我带来了一些问题。这是我的XML代码:(尚未完成)我得到的错误是在代码的第一行它说“错误:在包'android'中找不到属性'xmlns'的资源标识符我一遍又一遍地检查代码,尝试刷新/重建项目,尝试删除该特定行等等,但似乎没有任何解决办法。那么,如果有人有一些想法?谢谢! 最佳答案 删除android:xmlns="http://schemas.android.com/apk/res/
我正在关注googleAndroidStudio第一个android应用程序教程。但是当我尝试向我的应用程序添加搜索栏时,我现在收到3个奇怪的错误。我现在就在这里,我按照教程添加了XML代码。http://developer.android.com/training/basics/actionbar/adding-buttons.html我得到的错误:Error:(5,23)Noresourcefoundthatmatchesthegivenname(at'icon'withvalue'@drawable/ic_action_search').Error:(6,24)Noresourc