android中很多时候,默认的TAB样式并不好看,我们能不能编写XML对其样式进行修改。
修改成 下图中的

现需:按上图中的,自定义样式的TAB布局例子 thanks
------解决方案--------------------
编写xml可能比较难吧,直接继承类,在tabhost基础上自己画
------解决方案--------------------
你看看我上传的资源,正好有你想要的。
------解决方案--------------------
我下了他的资源发给你了
------解决方案--------------------
一个tabhost + selector 搞定
------解决方案--------------------
public class TestTabHostActivity extends TabActivity {
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();
}
------解决方案--------------------
private void 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);
}
}
------解决方案--------------------
private void makeTab() {
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可以结贴了