Android 目前最流行的 底部导航栏 用什么做的
1个回答
2017-01-15 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
很多android应用底部都有一个底部导航栏,方便用户在使用过程中随意切换。目前常用的做法有三种:一种是使用自定义tabHost,一种是使用activityGroup,一种是结合FrameLayout实现。再做了多款应用后,为了节约开发周期,封装了一个抽象类,只要三步便可完成底部栏的生成及不同页面的调用。
public class ActivitycollectiondemoActivity extends ActivityCollection {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setBottomTabBackground(resId);// 设置底部导航背景图
@Override
protected boolean isShowWindowFeature() {
return true;//设置是否显示title;
@Override
protected ListIndicatorInfo> setDrawableCollections() {
ListIndicatorInfo> IndicatorInfos = new ArrayListIndicatorInfo>();
IndicatorInfo indicatorInfo_1 = new IndicatorInfo(R.drawable.baby1,
R.drawable.baby1_s, R.string.baby1, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity01.class));
IndicatorInfo indicatorInfo_2 = new IndicatorInfo(R.drawable.baby2,
R.drawable.baby2_s, R.string.baby2, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity02.class));
IndicatorInfo indicatorInfo_3 = new IndicatorInfo(R.drawable.baby3,
R.drawable.baby3_s, R.string.baby3, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity03.class));
IndicatorInfo indicatorInfo_4 = new IndicatorInfo(R.drawable.baby4,
R.drawable.baby4_s, R.string.baby4, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity04.class));
IndicatorInfos.add(indicatorInfo_1);
IndicatorInfos.add(indicatorInfo_2);
IndicatorInfos.add(indicatorInfo_3);
IndicatorInfos.add(indicatorInfo_4);
return IndicatorInfos;
第一步:导入jar包;
第二步:让自己的homeactivity 继承ActivityCollection类;
第三步:将自己的图片资源及跳转intent放入list中,设置可选项;
雏形就形成啦!
public class ActivitycollectiondemoActivity extends ActivityCollection {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setBottomTabBackground(resId);// 设置底部导航背景图
@Override
protected boolean isShowWindowFeature() {
return true;//设置是否显示title;
@Override
protected ListIndicatorInfo> setDrawableCollections() {
ListIndicatorInfo> IndicatorInfos = new ArrayListIndicatorInfo>();
IndicatorInfo indicatorInfo_1 = new IndicatorInfo(R.drawable.baby1,
R.drawable.baby1_s, R.string.baby1, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity01.class));
IndicatorInfo indicatorInfo_2 = new IndicatorInfo(R.drawable.baby2,
R.drawable.baby2_s, R.string.baby2, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity02.class));
IndicatorInfo indicatorInfo_3 = new IndicatorInfo(R.drawable.baby3,
R.drawable.baby3_s, R.string.baby3, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity03.class));
IndicatorInfo indicatorInfo_4 = new IndicatorInfo(R.drawable.baby4,
R.drawable.baby4_s, R.string.baby4, 12, Color.WHITE,
new Intent(ActivitycollectiondemoActivity.this,
Activity04.class));
IndicatorInfos.add(indicatorInfo_1);
IndicatorInfos.add(indicatorInfo_2);
IndicatorInfos.add(indicatorInfo_3);
IndicatorInfos.add(indicatorInfo_4);
return IndicatorInfos;
第一步:导入jar包;
第二步:让自己的homeactivity 继承ActivityCollection类;
第三步:将自己的图片资源及跳转intent放入list中,设置可选项;
雏形就形成啦!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询