AndroidStudio使用之仿微信首页界面
介绍与分析AS实现微信首页的流程,
并附有源码链接: 码云
仿微信
(一)文件目录
(二)界面分析
1.top.xml
2.bottom.xml
3.tab01.xml
4.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:orientation="vertical">
<include layout="@layout/top" />
<FrameLayout
android:id="@+id/id_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<include layout="@layout/bottom"/>
</LinearLayout>
(三)动态切换
1.展示效果
2.功能分析
主要运用了fragment
Fragment的优势有以下几点:
模块化(Modularity):不必把所有代码全部写在Activity中,而是把代码写在各自的Fragment中。
可重用(Reusability):多个Activity可以重用一个Fragment。
可适配(Adaptability):根据硬件的屏幕尺寸、方向等,能更方便地实现不同的布局,提升用户体验。
#关键代码
package com.example.wechat;
import android.app.Activity;
import android.os