栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

移动开发——实现微信APP门户界面设计

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

移动开发——实现微信APP门户界面设计

移动开发——实现微信APP门户界面设计
  • 顶部界面设计
  • 底部界面设计
    • 底部界面布局
    • 图片和文字的颜色切换
  • 主体界面设计
  • 界面切换实现
    • 初始化成员参数
    • 默认显示微信菜单
    • Fragment切换的实现
    • 图片文字颜色切换
    • 重写点击事件的监听方法
    • 重写OnCreate方法
  • APP展示
  • 源代码

顶部界面设计


首先我们要实现的是顶部的标题,在此建立一个top.xml文件,使用水平线性布局,将一个TextView组件放入界面。其次设置组件的属性。

底部界面设计

底部界面布局

建立一个bottom.xml的文件,使用水平线性布局,拉入4个垂直线性布局的LinearLayout组件,在每个LinearLayout组件中放入一个TextView组件和一个imgView组件,设置各个组件的属性。

图片和文字的颜色切换

将下载好的图片拉进drawable的文件中,添加四个图片颜色切换的Drawable Resource File和一个文字颜色切换的Drawable Resource File。

图片颜色切换代码(以第一个为例):



    
    

文字颜色切换代码



    
    

主体界面设计


把activity_main.xml文件改为垂直线性布局,拉入一个frameLayout组件,在其中添加四个frameLayout组件作为四个界面。

新建四个Fragment类,在其中添加一个TextView组件提示此时的界面,修改各个组件的属性。

界面切换实现 初始化成员参数
private LinearLayout linearWx,linearTxl,linearFx,linearW;
private ImageView imgWx,imgTxl,imgFx,imgW,imgCur;
private TextView textWx,textTxl,textFx,textW,textCur;
private void initFun(){
        linearWx = findViewById(R.id.wx_linear);
        linearWx.setOnClickListener(this);
        linearTxl = findViewById(R.id.txl_linear);
        linearTxl.setOnClickListener(this);
        linearFx = findViewById(R.id.fx_linear);
        linearFx.setOnClickListener(this);
        linearW = findViewById(R.id.w_linear);
        linearW.setOnClickListener(this);

        imgWx = findViewById(R.id.imageView);
        imgTxl = findViewById(R.id.imageView2);
        imgFx = findViewById(R.id.imageView3);
        imgW = findViewById(R.id.imageView4);
        imgCur = findViewById(R.id.imageView);

        textWx = findViewById(R.id.textView);
        textTxl = findViewById(R.id.textView2);
        textFx = findViewById(R.id.textView3);
        textW = findViewById(R.id.textView4);
        textCur = findViewById(R.id.textView);
    }
默认显示微信菜单
private void addFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.add(R.id.body, fragment);
        transaction.commit();
    }
Fragment切换的实现
private void changeFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.body, fragment);
        transaction.commit();
    }
图片文字颜色切换
	private void colorChange(int id){
        textCur.setSelected(false);
        imgCur.setSelected(false);
        switch (id){
            case 1:
                imgWx.setSelected(true);
                imgCur=imgWx;
                textWx.setSelected(true);
                textCur=textWx;
                break;
            case 2:
                imgTxl.setSelected(true);
                imgCur=imgTxl;
                textTxl.setSelected(true);
                textCur=textTxl;
                break;
            case 3:
                imgFx.setSelected(true);
                imgCur=imgFx;
                textFx.setSelected(true);
                textCur=textFx;
                break;
            case 4:
                imgW.setSelected(true);
                imgCur=imgW;
                textW.setSelected(true);
                textCur=textW;
                break;
            default:
                break;
        }
    }
重写点击事件的监听方法
@Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.wx_linear:
                changeFragment(new BodyWx());
                colorChange(1);
                break;
            case R.id.txl_linear:
                changeFragment(new BodyTxl());
                colorChange(2);
                break;
            case R.id.fx_linear:
                changeFragment(new BodyFx());
                colorChange(3);
                break;
            case R.id.w_linear:
                changeFragment(new BodyW());
                colorChange(4);
                break;
            default:
                break;
        }
    }
重写OnCreate方法
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
	initFun();
    addFragment(new BodyWx());
    imgWx.setSelected(true);
    textWx.setSelected(true);
}
APP展示

源代码

gitee地址

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/305712.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号