截图:

布局:

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

样式:

主要java代码:

package com.shanjing.hotattention.activity;import android.Manifest;import android.content.Intent;import android.content.pm.PackageManager;import android.graphics.Bitmap;import android.graphics.Color;import android.os.Bundle;import android.support.annotation.NonNull;import android.support.v4.app.ActivityCompat;import android.support.v4.app.FragmentTransaction;import android.support.v4.content.ContextCompat;import android.view.View;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.Toast;import com.alibaba.android.arouter.facade.annotation.Route;import com.base.commonlib.BaseActivity;import com.base.commonlib.utils.StatusBarUtil;import com.base.commonlib.zxing.android.CaptureActivity;import com.shanjing.hotattention.R;import com.shanjing.hotattention.fragment.HotHomeFragment;import com.shanjing.hotattention.fragment.HotMallFragment;import com.shanjing.hotattention.fragment.HotMyFragment;import com.shanjing.hotattention.fragment.HotVideoFragment;import java.io.ByteArrayOutputStream;@Route(path = "/hotattention/main")public class HotAttentionHomeActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {    public RadioGroup rg;    public LinearLayout ll_sign;    private RadioButton rb_home, rb_mall, rb_video, rb_my;    private HotHomeFragment hotHomeFragment;    private HotMallFragment hotMallFragment;    private HotVideoFragment hotVideoFragment;    private HotMyFragment hotMyFragment;    private void assignViews() {        iv_scan = findViewById(R.id.iv_scan);        rg = findViewById(R.id.rg);        ll_sign = findViewById(R.id.ll_sign);        rb_home = findViewById(R.id.rb_home);        rb_mall = findViewById(R.id.rb_mall);        rb_video = findViewById(R.id.rb_video);        rb_my = findViewById(R.id.rb_my);        rg.setOnCheckedChangeListener(this);        ll_sign.setOnClickListener(this);        rb_home.setChecked(true);    }    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_hot_attention_home);        //用来设置整体下移,状态栏沉浸        StatusBarUtil.getStatusBarHeight(HotAttentionHomeActivity.this);        StatusBarUtil.setRootViewFitsSystemWindows(this, false);        StatusBarUtil.setStatusBarColor(HotAttentionHomeActivity.this, Color.parseColor("#ffffff"));//设置背景颜色        assignViews();    }    @Override    public void onCheckedChanged(RadioGroup group, int checkedId) {        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();        hideAllFragment(transaction);        switch (checkedId) {            case R.id.rb_home:                if (hotHomeFragment == null) {                    hotHomeFragment = new HotHomeFragment();                    transaction.add(R.id.fragment_container, hotHomeFragment);                } else {                    transaction.show(hotHomeFragment);                }                break;            case R.id.rb_mall:                if (hotMallFragment == null) {                    hotMallFragment = new HotMallFragment();                    transaction.add(R.id.fragment_container, hotMallFragment);                } else {                    transaction.show(hotMallFragment);                }                break;            case R.id.rb_video:                if (hotVideoFragment == null) {                    hotVideoFragment = new HotVideoFragment();                    transaction.add(R.id.fragment_container, hotVideoFragment);                } else {                    transaction.show(hotVideoFragment);                }                break;            case R.id.rb_my:                if (hotMyFragment == null) {                    hotMyFragment = new HotMyFragment();                    transaction.add(R.id.fragment_container, hotMyFragment);                } else {                    transaction.show(hotMyFragment);                }                break;        }        transaction.commit();    }    public void hideAllFragment(FragmentTransaction transaction) {        if (hotHomeFragment != null) {            transaction.hide(hotHomeFragment);        }        if (hotMallFragment != null) {            transaction.hide(hotMallFragment);        }        if (hotVideoFragment != null) {            transaction.hide(hotVideoFragment);        }        if (hotMyFragment != null) {            transaction.hide(hotMyFragment);        }    }    @Override    public void onClick(View v) {        int i = v.getId();        if (i == R.id.ll_sign) {//跳转到发布页            startActivity(new Intent(this, IssueActivity.class));        }    }}

再新建几个fragment作为各个模块就可以了

 

更多相关文章

  1. Android(安卓)通用Dialog中设置RecyclerView
  2. 有关ImageView的圆角或弧度角设置
  3. 网络获取图片实现无线自动轮播
  4. android 批量上传图片
  5. EditText中inputType="number"还可输入字母的设置
  6. Android设置屏幕方向
  7. Android——API23以上需要的动态权限
  8. MediaRecorder和MediaPlayer的简单使用
  9. Renderer (专门用于渲染3D 的接口 Renderer )()

随机推荐

  1. Android串口操作,简化android-serialport-
  2. Android 上进行签名的方法
  3. Android 文件读写工具类
  4. 数据存储之五网络数据交互
  5. Android获取文件的MD5值
  6. Rk3399 android7.1 camera 分析
  7. Android 用源代码写layout布局
  8. Android 系统版本
  9. android popupwindow 中listview 无法点
  10. Android 获得屏幕大小