android中很多时候,默认的TAB样式并不好看,我们能不能编写XML对其样式进行修改。修改成 下图中的现需:按上图中的,自定义样式的TAB布局例子 thanks
解决方案 »
- 怎麼讓Android手機上的Sim卡工具包顯示出來?
- FragmentActivity 在切换 Fragment时触发什么事件
- 高分求phonegap打包后遇到的问题
- 帮忙看看程序为什么强制停止
- 如何在email附件中添加一个拍摄照相的功能
- Android 多个对象共用一个onClick事件,如何得到触发该事件的是哪个对象
- android利用jni获取自己apk的签名。
- 关于构想的移动web应用程序设计框架的思考
- 如何继承多个Activity?挺简单的,是不是我想多了
- 求助:Android使用adb+socket连接PC端传输文件会消耗流量吗?还是只走usb数据线路,不会消耗流量?求大佬解释~
- Nexus 7平板上ZXing不能识别针式或喷墨打印机的条码.能换成条码枪用吗?
- android弹窗效果怎么搞
你的资源,我下载不了,你能用email发给我吗?thanks
我的email: [email protected]
再问3楼和5楼:<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/onselect" />
<item
android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/onselect" />
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/onselect" />
<item
android:state_pressed="true"
android:drawable="@drawable/onselect" />
</selector>1 这个xml是用来设置,选中某选项时,会跟上一背景图,对吗
2 现如果要在选中某选项时,还要再把选中项的文字的颜色变成红色,怎么实现呀
thanks
是在6楼提到的selector中写程序吗?还是?
private TabWidget tabWidget;
Resources res;
TabHost tabHost;
TabHost.TabSpec spec;
Intent intent;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
makeTab();
processTab();
}
tabWidget = (TabWidget) findViewById(android.R.id.tabs);
for (int i = 0; i < tabWidget.getChildCount(); i++) {
final TextView textView = (TextView) tabWidget.getChildAt(i).findViewById(R.id.tabtext);
textView.setTextColor(Color.BLUE);
}
}
res = getResources();
tabHost = getTabHost();
View tabView = View.inflate(this, R.layout.tab_view, null);
ImageView imageView = (ImageView) tabView.findViewById(R.id.tabimage);
imageView.setImageResource(R.drawable.e010);
TextView textView = (TextView) tabView.findViewById(R.id.tabtext);
textView.setText("我不懂");
intent = new Intent().setClass(this, TestCalendarActivity.class);
spec = tabHost.newTabSpec("first").setIndicator(tabView)
.setContent(intent);
tabHost.addTab(spec);
对啊,tabhost是一个布局 里面可以放这些:头条,都市。等等
但是这个头条按下的效果,非按下的效果可以在selector中实现至于头条对应的内容,就需要额外一个布局了 ,扯远了 。有点晕温馨提示:LZ可以结贴了
public void onTabChanged(String tabId) {
//tabId值为要切换到的tab页的索引位置
int tabID = Integer.valueOf(tabId);
for (int i = 0; i < tabWidget.getChildCount(); i++)
{
if (i == tabID)
{
tabWidget.getChildAt(Integer.valueOf(i));
final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
textView.setTextColor(0xffFEFFFF);
}
else
{
tabWidget.getChildAt(Integer.valueOf(i));
final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
textView.setTextColor(0xff767674);
}
}
}