前言:项目第二版刚上线没多久,产品又对需求进行了大改动,以前用的是左滑菜单,现在又要换成底部导航栏,于是今天又苦逼加班了.花了几个小时实现了一个底部导航栏的demo,然后总结一下.写一篇博客.供自己以后参考.也可以给没有做过的朋友进行参考.以后大家有类似的功能就可以在我的demo上就行修改.

一.先上效果图:   本来是打算用FragmentTabHost实现的,但是中间那个按钮有点麻烦,想到我们项目好几个产品经理,并且经常改需求,于是最后决定  用 TextView+Fragment去实现.

二.查看代码实现.代码是我们最好的老师.

主界面布局文件  activity_main.xml   外层一个FrameLayout+ImageView+LinearLayout     TextView选中跟未选中时 图片和颜色 切换都用布局去实现.

1).FrameLayout  用于显示fragment

2).ImageView  显示底部最中间那个图标

3).LinearLayout  显示底部四个图标   我这里用weight分成了5份,第三个控件啥都没有就用View控件占了一个位置

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent" >
  5.  
  6. <FrameLayout
  7. android:id="@+id/main_container"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. android:layout_above="@+id/view_line"/>
  11.  
  12. <View
  13. android:id="@+id/view_line"
  14. android:layout_height="1dp"
  15. android:layout_width="match_parent"
  16. android:background="#DCDBDB"
  17. android:layout_above="@+id/rl_bottom"/>
  18.  
  19. <LinearLayout
  20. android:id="@+id/rl_bottom"
  21. android:layout_width="match_parent"
  22. android:layout_height="wrap_content"
  23. android:layout_alignParentBottom="true"
  24. android:paddingTop="5dp"
  25. android:paddingBottom="5dp"
  26. android:background="#F2F2F2"
  27. android:orientation="horizontal" >
  28.  
  29. <TextView
  30. android:id="@+id/tv_main"
  31. android:layout_width="0dp"
  32. android:layout_height="wrap_content"
  33. android:layout_gravity="center"
  34. android:layout_weight="1"
  35. android:drawableTop="@drawable/tab_item_main_img_selector"
  36. android:drawablePadding="@dimen/main_tab_item_image_and_text"
  37. android:focusable="true"
  38. android:gravity="center"
  39. android:text="@string/main"
  40. android:textColor="@drawable/tabitem_txt_sel" />
  41.  
  42. <TextView
  43. android:id="@+id/tv_dynamic"
  44. android:layout_width="0dp"
  45. android:layout_height="wrap_content"
  46. android:layout_gravity="center"
  47. android:layout_weight="1"
  48. android:drawableTop="@drawable/tab_item_dynamic_img_selector"
  49. android:drawablePadding="@dimen/main_tab_item_image_and_text"
  50. android:focusable="true"
  51. android:gravity="center"
  52. android:text="@string/dynamic"
  53. android:textColor="@drawable/tabitem_txt_sel" />
  54.  
  55. <View
  56. android:layout_width="0dp"
  57. android:layout_height="match_parent"
  58. android:layout_weight="1" />
  59.  
  60. <TextView
  61. android:id="@+id/tv_message"
  62. android:layout_width="0dp"
  63. android:layout_height="wrap_content"
  64. android:layout_gravity="center"
  65. android:layout_weight="1"
  66. android:drawableTop="@drawable/tab_item_message_img_selector"
  67. android:drawablePadding="@dimen/main_tab_item_image_and_text"
  68. android:focusable="true"
  69. android:gravity="center"
  70. android:text="@string/message"
  71. android:textColor="@drawable/tabitem_txt_sel" />
  72.  
  73. <TextView
  74. android:id="@+id/tv_person"
  75. android:layout_width="0dp"
  76. android:layout_height="wrap_content"
  77. android:layout_gravity="center"
  78. android:layout_weight="1"
  79. android:drawableTop="@drawable/tab_item_person_img_selector"
  80. android:drawablePadding="@dimen/main_tab_item_image_and_text"
  81. android:focusable="true"
  82. android:gravity="center"
  83. android:text="@string/person"
  84. android:textColor="@drawable/tabitem_txt_sel"/>
  85. </LinearLayout>
  86.  
  87. <ImageView
  88. android:id="@+id/iv_make"
  89. android:layout_width="wrap_content"
  90. android:layout_height="wrap_content"
  91. android:layout_alignParentBottom="true"
  92. android:layout_centerHorizontal="true"
  93. android:paddingBottom="10dp"
  94. android:src="@drawable/icon_tab_make_select"/>
  95.  
  96. </RelativeLayout>

图片选择器   tab_item_main_img_selector.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  3. <!-- Non focused states -->
  4. <item android:drawable="@drawable/icon_tab_main_normal" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
  5. <item android:drawable="@drawable/icon_tab_main_select" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
  6. <!-- Focused states -->
  7. <item android:drawable="@drawable/icon_tab_main_select" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>
  8. <item android:drawable="@drawable/icon_tab_main_select" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
  9. <!-- Pressed -->
  10. <item android:drawable="@drawable/icon_tab_main_select" android:state_pressed="true" android:state_selected="true"/>
  11. <item android:drawable="@drawable/icon_tab_main_select" android:state_pressed="true"/>
  12. </selector>

文字颜色选择器   tabitem_txt_sel.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  3.  
  4. <!-- Non focused states -->
  5. <item android:state_focused="false" android:state_pressed="false" android:state_selected="false" android:color="@color/main_tab_item_text_normal"/>
  6. <item android:state_focused="false" android:state_pressed="false" android:state_selected="true" android:color="@color/main_tab_item_text_select"/>
  7.  
  8. <!-- Focused states -->
  9. <item android:state_focused="true" android:state_pressed="false" android:state_selected="false" android:color="@color/main_tab_item_text_select"/>
  10. <item android:state_focused="true" android:state_pressed="false" android:state_selected="true" android:color="@color/main_tab_item_text_select"/>
  11.  
  12. <!-- Pressed -->
  13. <item android:state_pressed="true" android:state_selected="true" android:color="@color/main_tab_item_text_select"/>
  14. <item android:state_pressed="true" android:color="@color/main_tab_item_text_select"/>
  15.  
  16. </selector>

MainActivity.java   对fragment的切换,底部图标颜色的切换.我也不详细介绍了.代码里面我都有写注释.

  1. /**
  2. * 对fragment的切换,底部图标颜色的切换
  3. * @author ansen
  4. * @create time 2015-09-08
  5. */
  6. public class MainActivity extends FragmentActivity {
  7. //要切换显示的四个Fragment
  8. private MainFragment mainFragment;
  9. private DynamicFragment dynamicFragment;
  10. private MessageFragment messageFragment;
  11. private PersonFragment personFragment;
  12.  
  13. private int currentId = R.id.tv_main;// 当前选中id,默认是主页
  14.  
  15. private TextView tvMain, tvDynamic, tvMessage, tvPerson;//底部四个TextView
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_main);
  21.  
  22. tvMain = (TextView) findViewById(R.id.tv_main);
  23. tvMain.setSelected(true);//首页默认选中
  24. tvDynamic = (TextView) findViewById(R.id.tv_dynamic);
  25. tvMessage = (TextView) findViewById(R.id.tv_message);
  26. tvPerson = (TextView) findViewById(R.id.tv_person);
  27.  
  28. /**
  29. * 默认加载首页
  30. */
  31. mainFragment = new MainFragment();
  32. getSupportFragmentManager().beginTransaction().add(R.id.main_container, mainFragment).commit();
  33.  
  34. tvMain.setOnClickListener(tabClickListener);
  35. tvDynamic.setOnClickListener(tabClickListener);
  36. tvMessage.setOnClickListener(tabClickListener);
  37. tvPerson.setOnClickListener(tabClickListener);
  38. findViewById(R.id.iv_make).setOnClickListener(onClickListener);
  39. }
  40.  
  41. private OnClickListener onClickListener=new OnClickListener() {
  42. @Override
  43. public void onClick(View v) {
  44. switch (v.getId()) {
  45. case R.id.iv_make:
  46. Intent intent=new Intent(MainActivity.this, MakeActivity.class);
  47. startActivity(intent);
  48. break;
  49. }
  50. }
  51. };
  52.  
  53. private OnClickListener tabClickListener = new OnClickListener() {
  54. @Override
  55. public void onClick(View v) {
  56. if (v.getId() != currentId) {//如果当前选中跟上次选中的一样,不需要处理
  57. changeSelect(v.getId());//改变图标跟文字颜色的选中
  58. changeFragment(v.getId());//fragment的切换
  59. currentId = v.getId();//设置选中id
  60. }
  61. }
  62. };
  63.  
  64. /**
  65. * 改变fragment的显示
  66. *
  67. * @param resId
  68. */
  69. private void changeFragment(int resId) {
  70. FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();//开启一个Fragment事务
  71.  
  72. hideFragments(transaction);//隐藏所有fragment
  73. if(resId==R.id.tv_main){//主页
  74. if(mainFragment==null){//如果为空先添加进来.不为空直接显示
  75. mainFragment = new MainFragment();
  76. transaction.add(R.id.main_container,mainFragment);
  77. }else {
  78. transaction.show(mainFragment);
  79. }
  80. }else if(resId==R.id.tv_dynamic){//动态
  81. if(dynamicFragment==null){
  82. dynamicFragment = new DynamicFragment();
  83. transaction.add(R.id.main_container,dynamicFragment);
  84. }else {
  85. transaction.show(dynamicFragment);
  86. }
  87. }else if(resId==R.id.tv_message){//消息中心
  88. if(messageFragment==null){
  89. messageFragment = new MessageFragment();
  90. transaction.add(R.id.main_container,messageFragment);
  91. }else {
  92. transaction.show(messageFragment);
  93. }
  94. }else if(resId==R.id.tv_person){//我
  95. if(personFragment==null){
  96. personFragment = new PersonFragment();
  97. transaction.add(R.id.main_container,personFragment);
  98. }else {
  99. transaction.show(personFragment);
  100. }
  101. }
  102. transaction.commit();//一定要记得提交事务
  103. }
  104.  
  105. /**
  106. * 显示之前隐藏所有fragment
  107. * @param transaction
  108. */
  109. private void hideFragments(FragmentTransaction transaction){
  110. if (mainFragment != null)//不为空才隐藏,如果不判断第一次会有空指针异常
  111. transaction.hide(mainFragment);
  112. if (dynamicFragment != null)
  113. transaction.hide(dynamicFragment);
  114. if (messageFragment != null)
  115. transaction.hide(messageFragment);
  116. if (personFragment != null)
  117. transaction.hide(personFragment);
  118. }
  119.  
  120. /**
  121. * 改变TextView选中颜色
  122. * @param resId
  123. */
  124. private void changeSelect(int resId) {
  125. tvMain.setSelected(false);
  126. tvDynamic.setSelected(false);
  127. tvMessage.setSelected(false);
  128. tvPerson.setSelected(false);
  129.  
  130. switch (resId) {
  131. case R.id.tv_main:
  132. tvMain.setSelected(true);
  133. break;
  134. case R.id.tv_dynamic:
  135. tvDynamic.setSelected(true);
  136. break;
  137. case R.id.tv_message:
  138. tvMessage.setSelected(true);
  139. break;
  140. case R.id.tv_person:
  141. tvPerson.setSelected(true);
  142. break;
  143. }
  144. }
  145. }

MainFragment.java  首页有三个页面(关注,推荐,动态),我用到了ViewPager滑动,增加了滑动指示状态.并且给标题栏的三个TextView设置了点击效果.

  1. /**
  2. * 首页
  3. * @author Ansen
  4. * @create time 2015-09-08
  5. */
  6. public class MainFragment extends Fragment {
  7. private ViewPager vPager;
  8. private List<Fragment> list = new ArrayList<Fragment>();
  9. private MessageGroupFragmentAdapter adapter;
  10.  
  11. private ImageView ivShapeCircle;
  12. private TextView tvFollow,tvRecommend,tvLocation;
  13.  
  14. private int offset=0;//偏移量216 我这边只是举例说明,不同手机值不一样
  15. private int currentIndex=1;
  16.  
  17. @Override
  18. public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
  19. View rootView = inflater.inflate(R.layout.fragment_main, null);
  20.  
  21. /**
  22. * 初始化三个Fragment 并且填充到ViewPager
  23. */
  24. vPager = (ViewPager) rootView.findViewById(R.id.viewpager_home);
  25. DynamicFragment dynamicFragment = new DynamicFragment();
  26. MessageFragment messageFragment = new MessageFragment();
  27. PersonFragment personFragment = new PersonFragment();
  28. list.add(dynamicFragment);
  29. list.add(messageFragment);
  30. list.add(personFragment);
  31. adapter = new MessageGroupFragmentAdapter(getActivity().getSupportFragmentManager(), list);
  32. vPager.setAdapter(adapter);
  33. vPager.setOffscreenPageLimit(2);
  34. vPager.setCurrentItem(1);
  35. vPager.setOnPageChangeListener(pageChangeListener);
  36.  
  37. ivShapeCircle = (ImageView) rootView.findViewById(R.id.iv_shape_circle);
  38.  
  39. tvFollow=(TextView) rootView.findViewById(R.id.tv_follow);
  40. tvRecommend=(TextView) rootView.findViewById(R.id.tv_recommend);
  41. tvRecommend.setSelected(true);//推荐默认选中
  42. tvLocation=(TextView) rootView.findViewById(R.id.tv_location);
  43.  
  44. /**
  45. * 标题栏三个按钮设置点击效果
  46. */
  47. tvFollow.setOnClickListener(clickListener);
  48. tvRecommend.setOnClickListener(clickListener);
  49. tvLocation.setOnClickListener(clickListener);
  50.  
  51. initCursorPosition();
  52. return rootView;
  53. }
  54.  
  55. private OnClickListener clickListener=new OnClickListener() {
  56. @Override
  57. public void onClick(View v) {
  58. switch (v.getId()) {
  59. case R.id.tv_follow:
  60. //当我们设置setCurrentItem的时候就会触发viewpager的OnPageChangeListener借口,
  61. //所以我们不需要去改变标题栏字体啥的
  62. vPager.setCurrentItem(0);
  63. break;
  64. case R.id.tv_recommend:
  65. vPager.setCurrentItem(1);
  66. break;
  67. case R.id.tv_location:
  68. vPager.setCurrentItem(2);
  69. break;
  70. }
  71. }
  72. };
  73.  
  74. private void initCursorPosition() {
  75. DisplayMetrics metric = new DisplayMetrics();
  76. getActivity().getWindowManager().getDefaultDisplay().getMetrics(metric);
  77. int width = metric.widthPixels;
  78. Matrix matrix = new Matrix();
  79.  
  80. //标题栏我用weight设置权重 分成5份
  81. //(width / 5) * 2 这里表示标题栏两个控件的宽度
  82. //(width / 10) 标题栏一个控件的2分之一
  83. //7 约等于原点宽度的一半
  84. matrix.postTranslate((width / 5) * 2 + (width / 10)-7,0);//图片平移
  85. ivShapeCircle.setImageMatrix(matrix);
  86.  
  87. //一个控件的宽度 我的手机宽度是1080/5=216 不同的手机宽度会不一样哦
  88. offset=(width / 5);
  89. }
  90.  
  91. /**
  92. * ViewPager滑动监听,用位移动画实现指示器效果
  93. *
  94. * TranslateAnimation 强调一个地方,无论你移动了多少次,现在停留在哪里,你的起始位置从未变化过.
  95. * 例如:我这个demo里面 推荐移动到了同城,指示器也停留到了同城下面,但是指示器在屏幕上的位置还是推荐下面.
  96. */
  97. private OnPageChangeListener pageChangeListener = new OnPageChangeListener() {
  98. @Override
  99. public void onPageSelected(int index) {
  100. changeTextColor(index);
  101. translateAnimation(index);
  102. }
  103.  
  104. @Override
  105. public void onPageScrolled(int arg0, float arg1, int arg2) {
  106. }
  107.  
  108. @Override
  109. public void onPageScrollStateChanged(int arg0) {
  110. }
  111. };
  112.  
  113. /**
  114. * 改变标题栏字体颜色
  115. * @param index
  116. */
  117. private void changeTextColor(int index){
  118. tvFollow.setSelected(false);
  119. tvRecommend.setSelected(false);
  120. tvLocation.setSelected(false);
  121.  
  122. switch (index) {
  123. case 0:
  124. tvFollow.setSelected(true);
  125. break;
  126. case 1:
  127. tvRecommend.setSelected(true);
  128. break;
  129. case 2:
  130. tvLocation.setSelected(true);
  131. break;
  132. }
  133. }
  134.  
  135. /**
  136. * 移动标题栏点点点...
  137. * @param index
  138. */
  139. private void translateAnimation(int index){
  140. TranslateAnimation animation = null;
  141. switch(index){
  142. case 0:
  143. if(currentIndex==1){//从推荐移动到关注 X坐标向左移动216
  144. animation=new TranslateAnimation(0,-offset,0,0);
  145. }else if (currentIndex == 2) {//从同城移动到关注 X坐标向左移动216*2 记住起始x坐标是同城那里
  146. animation = new TranslateAnimation(offset, -offset, 0, 0);
  147. }
  148. break;
  149. case 1:
  150. if(currentIndex==0){//从关注移动到推荐 X坐标向右移动216
  151. animation=new TranslateAnimation(-offset,0,0,0);
  152. }else if(currentIndex==2){//从同城移动到推荐 X坐标向左移动216
  153. animation=new TranslateAnimation(offset, 0,0,0);
  154. }
  155. break;
  156. case 2:
  157. if (currentIndex == 0) {//从关注移动到同城 X坐标向右移动216*2 记住起始x坐标是关注那里
  158. animation = new TranslateAnimation(-offset, offset, 0, 0);
  159. } else if(currentIndex==1){//从推荐移动到同城 X坐标向右移动216
  160. animation=new TranslateAnimation(0,offset,0,0);
  161. }
  162. break;
  163. }
  164. animation.setFillAfter(true);
  165. animation.setDuration(300);
  166. ivShapeCircle.startAnimation(animation);
  167.  
  168. currentIndex=index;
  169. }
  170. }

首页显示的MainFragment.java的布局文件  fragment_main.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent" >
  5.  
  6. <LinearLayout
  7. android:id="@+id/ll_title"
  8. android:layout_width="match_parent"
  9. android:layout_height="44dp"
  10. android:background="#00ceaa"
  11. android:orientation="vertical" >
  12.  
  13. <LinearLayout
  14. android:layout_width="match_parent"
  15. android:layout_height="30dp"
  16. android:orientation="horizontal" >
  17.  
  18. <View
  19. android:id="@+id/view_empty"
  20. android:layout_width="0dp"
  21. android:layout_height="wrap_content"
  22. android:layout_weight="1" />
  23.  
  24. <TextView
  25. android:id="@+id/tv_follow"
  26. android:layout_width="0dp"
  27. android:layout_height="wrap_content"
  28. android:layout_weight="1"
  29. android:paddingTop="5dp"
  30. android:text="关注"
  31. android:gravity="center_horizontal"
  32. android:textColor="@drawable/main_title_txt_sel"
  33. android:textSize="20sp" />
  34.  
  35. <TextView
  36. android:id="@+id/tv_recommend"
  37. android:layout_width="0dp"
  38. android:layout_height="wrap_content"
  39. android:layout_weight="1"
  40. android:paddingTop="5dp"
  41. android:text="推荐"
  42. android:gravity="center_horizontal"
  43. android:textColor="@drawable/main_title_txt_sel"
  44. android:textSize="20sp" />
  45.  
  46. <TextView
  47. android:id="@+id/tv_location"
  48. android:layout_width="0dp"
  49. android:layout_height="wrap_content"
  50. android:layout_weight="1"
  51. android:paddingTop="5dp"
  52. android:text="同城"
  53. android:gravity="center_horizontal"
  54. android:textColor="@drawable/main_title_txt_sel"
  55. android:textSize="20sp" />
  56.  
  57. <View
  58. android:layout_width="0dp"
  59. android:layout_height="wrap_content"
  60. android:layout_weight="1" />
  61. </LinearLayout>
  62.  
  63. <ImageView
  64. android:id="@+id/iv_shape_circle"
  65. android:layout_width="fill_parent"
  66. android:layout_height="wrap_content"
  67. android:layout_marginTop="2dp"
  68. android:scaleType="matrix"
  69. android:src="@drawable/shape_circle" />
  70. </LinearLayout>
  71.  
  72. <android.support.v4.view.ViewPager
  73. android:id="@+id/viewpager_home"
  74. android:layout_width="match_parent"
  75. android:layout_height="match_parent"
  76. android:layout_below="@+id/ll_title" />
  77.  
  78. </RelativeLayout>

MessageGroupFragmentAdapter.java    ViewPager的适配器.

  1. public class MessageGroupFragmentAdapter extends FragmentStatePagerAdapter {
  2. private List<Fragment>list;
  3. public MessageGroupFragmentAdapter(FragmentManager fm, List<Fragment> list) {
  4. super(fm);
  5. this.list = list;
  6. }
  7.  
  8. public MessageGroupFragmentAdapter(FragmentManager fm) {
  9. super(fm);
  10. }
  11.  
  12. @Override
  13. public Fragment getItem(int arg0) {
  14. return list.get(arg0);
  15. }
  16.  
  17. @Override
  18. public int getCount() {
  19. return list.size();
  20. }
  21. }

这个demo的核心代码就在这里了,其他几个Fragment的代码跟布局文件我就不贴出来了....有需要的可以去下载我的源码.....又到了10点半了....回家.....

点击下载源码

相关文章:EventBus实现activity跟fragment交互数据

后记:如果你运行之后首页会出现空白的情况,viewpager滑动也会出现问题了,那是MainFragment类初始化viewpager的adpater有问题.

修改后代码如下,大概在MainFragment中125行:

adapter = new MessageGroupFragmentAdapter(getChildFragmentManager(), list);

TextView+Fragment实现底部导航栏的更多相关文章

  1. [置顶] xamarin android Fragment实现底部导航栏

    前段时间写了篇关于Fragment的文章,介绍了基础的概念,用静态和动态的方式加载Fragment  Xamarin Android Fragment的两种加载方式.下面的这个例子介绍xamarin ...

  2. Android学习笔记- Fragment实例 底部导航栏的实现

    1.要实现的效果图以及工程目录结构: 先看看效果图吧: 接着看看我们的工程的目录结构: 2.实现流程: Step 1:写下底部选项的一些资源文件 我们从图上可以看到,我们底部的每一项点击的时候都有不同 ...

  3. 使用BottomNavigationView+ViewPager+Fragment的底部导航栏

    2019独角兽企业重金招聘Python工程师标准>>> 使用BottomNavigationView做底部工具栏,使用ViewPager做页面切换,使用Fragment完成每个页面的 ...

  4. 使用fragment添加底部导航栏

    切记:fragment一定要放在framlayout中,不然不会被替换完全(就是切换之后原来的fagment可能还会存在) main.xml <LinearLayout xmlns:androi ...

  5. 二、Fragment+RadioButton实现底部导航栏

    在App中经常看到这样的tab底部导航栏   那么这种效果是如何实现,实现的方式有很多种,最常见的就是使用Fragment+RadioButton去实现.下面我们来写一个例子 首先我们先在activi ...

  6. AndroidStudio制作底部导航栏以及用Fragment实现切换功能

    前言 大家好,给大家带来AndroidStudio制作底部导航栏以及用Fragment实现切换功能的概述,希望你们喜欢 学习目标 AndroidStudio制作底部导航栏以及用Fragment实现切换 ...

  7. Android商城开发系列(三)——使用Fragment+RadioButton实现商城底部导航栏

    在商城第一篇的开篇当中,我们看到商城的效果图里面有一个底部导航栏效果,如下图所示: 今天我们就来实现商城底部导航栏,最终效果图如下所示:   那么这种效果是如何实现,实现的方式有很多种,最常见的就是使 ...

  8. Android_ViewPager+Fragment实现页面滑动和底部导航栏

    1.Xml中底部导航栏由一个RadioGroup组成,其上是ViewPager. <?xml version="1.0" encoding="utf-8" ...

  9. Android底部导航栏——FrameLayout + RadioGroup

    原创文章,转载请注明出处http://www.cnblogs.com/baipengzhan/p/6285881.html Android底部导航栏有多种实现方式,本文详细介绍FrameLayout ...

随机推荐

  1. java cookie 工具类

    package com.xxx.xxx.xxx.xxx; import java.net.URLDecoder; import java.net.URLEncoder; import javax.se ...

  2. java记录

    1. 包装类与自动装箱问题:在justjavac的博客上看到翻译的一篇文章 离开java,寻找更佳语言的十大理由 中关于自动装箱的一个描述: 这个特性是为了解决因原生类型的存在所导致的问题,在Java ...

  3. Android事件分发小结

      ******** ******** 第一部分: 介绍说明 ******** ********        个人感觉在做交互的时候, 对于Android的按键分发的理解还是比较重要的. 这些内容在 ...

  4. Vuforia点击屏幕自动对焦,过滤UGUI的按钮

    //点击屏幕自对对焦 #if UNITY_EDITOR )) #elif UNITY_ANDROID || UNITY_IPHONE && Input.GetTouch().phase ...

  5. ajax post提交form表单 报400错误 解决方法

    昨天晚上做项目遇到了一个奇怪的问题,我用ajax提交一个form表单,后台Java方法用的是一个实体接,但是他根本不进方法体中,直接给我一个400的错误,一开始我以为是我路径的问题(尴尬),结果直接访 ...

  6. 利用@media screen实现网页布局的自适应

    利用@media screen实现网页布局的自适应 优点:无需插件和手机主题,对移动设备友好,能够适应各种窗口大小.只需在CSS中添加@media screen属性,根据浏览器宽度判断并输出不同的长宽 ...

  7. 20145337 GDB调试汇编堆栈过程分析

    20145337 GDB调试汇编堆栈过程分析 测试代码 #include<stdio.h> short addend1 = 1; static int addend2 = 2; const ...

  8. Web 入门之 XML

      160916   1. 什么是XML?   XML 是 EXtensible Markup Language 的缩写,称为可扩展标记语言,所谓可扩展指用户可根据XML规则自定义标记.例子1-1 = ...

  9. 使用PowerShell找出具体某个站点所使用的模板(Web Template)名称?

    $web = get-spweb –identity http://servername/sites/site/web #得到站点的对象 $web.WebTemplate #得到WebTemplate ...

  10. 《.NET之美》消息及勘误

    <.NET之美>消息及勘误 编辑最终还是采用了<.NET之美>作为书名,尽管我一直觉得这个名字有点文艺了,而更倾向于使用<.NET专题解析>这个名称. 目前已经可以 ...