为什么80%的码农都做不了架构师?>>>   

先看下实现效果图

MainActivity代码

public class MainActivity extends BaseActivity implementsRadioGroup.OnCheckedChangeListener {private RadioGroup radioGroup;private FrameLayout fragmentRoot;private HomeFragment homeFragment;private CardFragment cardFragment;private CollectionFragment collectionFragment;private SettingFragment settingFragment;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);//软键盘弹出后页面整体上移initView();showFragment(0);}private void initView() {radioGroup = (RadioGroup) findViewById(R.id.bottomRg);radioGroup.setOnCheckedChangeListener(this);fragmentRoot = (FrameLayout) findViewById(R.id.fragmentRoot);homeFragment = new HomeFragment();cardFragment=new CardFragment();collectionFragment=new CollectionFragment();settingFragment=new SettingFragment();}private void showFragment(int index) {Fragment fragment = null;switch (index) {case 0:fragment = homeFragment;break;case 1:fragment = cardFragment;break;case 2:fragment = collectionFragment;break;case 3:fragment = settingFragment;break;default:break;}FragmentManager fm =getFragmentManager();// 获取Fragment管理器FragmentTransaction ft = fm.beginTransaction();ft.replace(R.id.fragmentRoot, fragment);ft.commit();}public void onCheckedChanged(RadioGroup group, int checkedId) {int selectIndex = 0;switch (checkedId) {case R.id.rbOne:selectIndex = 0;break;case R.id.rbTwo:selectIndex = 1;break;case R.id.rbThree:selectIndex = 2;break;case R.id.rbFour:selectIndex = 3;break;}showCurTab(selectIndex, checkedId, true);}private void showCurTab(int index, int checkedId, boolean isSelect) {radioGroup.check(checkedId);showFragment(index);for (int i = 0; i < radioGroup.getChildCount(); i++) {if (i == index) {changeTabImage(i, true);} else {changeTabImage(i, false);}}}private void changeTabImage(int index, boolean isSelect) {RadioButton rButton = (RadioButton) radioGroup.getChildAt(index);switch (index) {case 0:if (isSelect) {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.home_select, 0, 0);rButton.setTextColor(getResources().getColor(R.color.color_white));} else {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.home, 0, 0);rButton.setTextColor(getResources().getColor(R.color.gray_color));}break;case 1:if (isSelect) {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.card_select, 0, 0);rButton.setTextColor(getResources().getColor(R.color.color_white));} else {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.card, 0, 0);rButton.setTextColor(getResources().getColor(R.color.gray_color));}break;case 2:if (isSelect) {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.collection_select, 0, 0);rButton.setTextColor(getResources().getColor(R.color.color_white));} else {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.collection, 0, 0);rButton.setTextColor(getResources().getColor(R.color.gray_color));}break;case 3:if (isSelect) {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.me_select, 0, 0);rButton.setTextColor(getResources().getColor(R.color.color_white));} else {rButton.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.me, 0, 0);rButton.setTextColor(getResources().getColor(R.color.gray_color));}break;}}int waitTime = 2000;long touchTime = 0;@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if(event.getAction() == KeyEvent.ACTION_DOWN && KeyEvent.KEYCODE_BACK == keyCode) {long currentTime = System.currentTimeMillis();if((currentTime-touchTime)>=waitTime) {//让Toast的显示时间和等待时间相同Toast.makeText(this, "再按一次退出", Toast.LENGTH_LONG).show();touchTime = currentTime;}else {finish();}return true;}return super.onKeyDown(keyCode, event);}}

activity_main.xml代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@color/color_white"android:orientation="vertical"tools:context=".Activity.MainActivity"><FrameLayoutandroid:id="@+id/fragmentRoot"android:layout_width="match_parent"android:layout_height="0dp"android:orientation="vertical"android:layout_weight="1"></FrameLayout><FrameLayoutandroid:id="@+id/fl_main"android:layout_width="match_parent"android:layout_height="50dp"android:background="@color/activity_title_bar_color"android:layout_alignParentBottom="true" ><RadioGroupandroid:id="@+id/bottomRg"android:layout_width="fill_parent"android:layout_height="match_parent"android:orientation="horizontal"android:paddingTop="8dp" ><RadioButtonandroid:id="@+id/rbOne"style="@style/footbar"android:layout_weight="1"android:checked="true"android:drawableTop="@drawable/home_button_select"android:text="@string/fragment_frist_page"android:textColor="@color/color_white"android:background="@android:color/transparent"android:textSize="@dimen/tab_text_size" /><RadioButtonandroid:id="@+id/rbTwo"style="@style/footbar"android:layout_weight="1"android:drawableTop="@drawable/card"android:text="@string/fragment_card_page"android:background="@android:color/transparent"android:textColor="@color/gray_color"android:textSize="@dimen/tab_text_size" /><RadioButtonandroid:id="@+id/rbThree"style="@style/footbar"android:layout_weight="1"android:drawableTop="@drawable/collection"android:text="@string/fragment_collection_page"android:background="@android:color/transparent"android:textColor="@color/gray_color"android:textSize="@dimen/tab_text_size" /><RadioButtonandroid:id="@+id/rbFour"style="@style/footbar"android:layout_weight="1"android:drawableTop="@drawable/me"android:text="@string/fragment_me_page"android:background="@android:color/transparent"android:textColor="@color/gray_color"android:textSize="@dimen/tab_text_size" /></RadioGroup></FrameLayout>
</LinearLayout>

res - -》values - -》styles.xml 文件中添加style标签

  <style name="footbar"><item name="android:layout_width">fill_parent</item><item name="android:layout_height">fill_parent</item><item name="android:textSize">10sp</item><item name="android:textColor">#FFFFFF</item> <!--白色--><item name="android:singleLine">true</item><item name="android:ellipsize">marquee</item><item name="android:button">@null</item><item name="android:gravity">bottom|center_horizontal</item><item name="android:paddingBottom">2dp</item></style>

转载于:https://my.oschina.net/fltsp/blog/896568

仿微信选项卡主页面创建相关推荐

  1. Kotlin高仿微信-项目实践58篇

    Kotlin高仿微信项目实践主要包含5大模块: 1.Web服务器 2.Kotlin客户端 3.Xmpp即时通讯服务器 4.视频通话服务器 5.腾讯云服务器 另外也有Flutter版本高仿微信功能,Fl ...

  2. Flutter高仿微信-项目实践59篇

    Flutter高仿微信(支持Android和IOS系统) Flutter高仿微信主要包含5大模块: 1.Web服务器 2.Flutter客户端 3.Xmpp即时通讯服务器 4.视频通话服务器 5.腾讯 ...

  3. Kotlin高仿微信-第6篇-主页-我的

     Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜 ...

  4. Flutter高仿微信-第3篇-主页

    Flutter高仿微信系列共59篇,从Flutter客户端.Kotlin客户端.Web服务器.数据库表结构.Xmpp即时通讯服务器.视频通话服务器.腾讯云服务器全面讲解. Flutter高仿微信-项目 ...

  5. android 微信创建群ui,Android控件:高仿微信主UI

    高仿微信主UI 之前在Android组件:Fragment切换后保存状态 一文中讲到了Fragment切换后,是如何保存原来的状态的,最重要的就是用add方法取代现在各种教程常见的replace方法. ...

  6. Kotlin高仿微信-第14篇-单聊-视频通话

    Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册.登录.主页.单聊(文本.表情.语音.图片.小视频.视频通话.语音通话.红包.转账).群聊.个人信息.朋友圈.支付服务.扫一扫.搜索 ...

  7. android仿微信拍摄视频教程,仿微信视频拍摄UI, 基于ffmpeg的视频录制编辑(上)

    本项目所使用的so库是VCamera,个人免费, 禁止商用,只用作demo演示 因为最近项目做了关于视频拍摄和视频处理的需求, 所以特来分享一下, 做了一个基于微信录制,  分析ffmpeg视频编辑的 ...

  8. 基于Flutter的仿微信聊天应用

    前言   作为当下风头正劲的跨端框架,flutter成为原生开发者和前端开发者争相试水的领域,笔者将通过一个仿微信聊天的应用,展现flutter的开发流程和相关工具链,旨在熟悉flutter的开发生态 ...

  9. android 点击图片动画效果,Android仿微信图片点击全屏效果

    废话不多说,先看下Android图片点击全屏效果: 先是微信的 再是模仿的 先说下实现原理,再一步步分析 这里总共有2个Activity一个就是主页,一个就是显示我们图片效果的页面,参数通过Inten ...

  10. 12、Flutter - 项目实战 - 仿微信(六)聊天页面

    Flutter - 项目实战 - 仿微信(六)聊天页面 接上篇:11.Flutter - 项目实战 - 仿微信(五)通讯录 详细代码参见Demo Demo地址 -> wechat_demo 其他 ...

最新文章

  1. Maven jdk.1.7
  2. base环境卸载python_20小时快速学习python数据分析实践1——相关软件一系列安装和基本操作熟悉(第0-1h)...
  3. stl vector 函数_vector :: pop_back()函数以及C ++ STL中的示例
  4. 打开word时出现“在加载ThisDocument时出现错误”
  5. Linux--安装yum源
  6. mysql 查询前一个月数据_mysql 查询当天、本周,本月,上一个月的数据......
  7. python 录入数据不重复_pythonDjango批量导入不重复数据
  8. 如何通过C#开发一个媒体播放器(中)
  9. Linux下配置CentOS7网络设置 获取ip地址
  10. edger多组差异性分析_edgeR基因表达差异分析
  11. 每天进步一点点 2016-10-28
  12. 普元EOS更新license
  13. Android 在一个APP内打开另一个APP
  14. Android百度地图
  15. 商务英语转计算机,BEC商务英语
  16. 【java学习笔记day01】运行第一个程序Helloworld!
  17. php发送指令给易语言,易语言发送信息代码数字指令编程整理
  18. karas 实现lstm 文本分类
  19. iOS中更新版权 Copyright
  20. STM32+ULN2003驱动步进电机

热门文章

  1. 系统性能评价的关键指标指标
  2. angular-route 和soket注意细节点
  3. 从angularJS看MVVM
  4. 搭建ssm中遇到的问题
  5. linux限制进程使用的cpu使用率
  6. 51nod 最长的循环节(对循环小数位的理解+快速幂+欧拉筛)
  7. JavaScript开发者的工具箱
  8. RIDE的底部的日志没显示处理
  9. SQL 中联合主键设为外键的问题
  10. Java开发笔记(一百四十四)实现FXML对应的控制器