开发学院手机开发Android 开发 Android 标签/TabActivity 深度研究 阅读

Android 标签/TabActivity 深度研究

 2010-06-19 17:46:00 来源:WEB开发网   
核心提示:radio2.setText("Radio B");rGroup.addView(radio2);layout.addView(rGroup,new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLay

radio2.setText("Radio B");

rGroup.addView(radio2);

layout.addView(rGroup,

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));

}

else if(id.equals(Tab3)){

LinearLayout.LayoutParams param3 =

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);

layout.addView(inflaterHelper.inflate(R.layout.hello, null),param3);

}

else if(id.equals(Tab4)){

TextView tv = new TextView(activity);

tv.setText("HelloTags!");

tv.setGravity(Gravity.CENTER);

layout.addView(tv);

}

return layout;

}

}

* 如何使用:

Java代码

CustomLayout ct = new CustomLayout(this);

tHost.addTab(tHost.newTabSpec(Tab4).setIndicator("Tab 4").setContent(ct));

CustomLayout ct = new CustomLayout(this);

tHost.addTab(tHost.newTabSpec(Tab4).setIndicator("Tab 4").setContent(ct));

* emulator 运行结果:

3. 改变标签布局

写道

可能很多人对TabActivity 不满意 原因之一:其很不美观 而不美观的根源就是:标签的问题 其图像和文字相互覆盖 导致的

那么 我们可以自己扩展么? 当然

写道

TabWidget 理解:

1. TabWidget 为 horizontal 的 LinearLayout

2. 且 其包含的标签又是一个RelativeLayout

3. 每个标签RelativeLayout 里面包含2个View: TextView ImageView

因此 我们甚至可以推算出其布局为:

Java代码

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="horizontal"

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:Android 标签 TabActivity

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接