Android Studio实现类似微信页面跳转

Android Studio --1.实现类似微信页面的跳转

通过fragment内嵌页面在activity中完成将多个页面显示在一起的布局,通过对不同button的监听,完成多个页面之间的跳转。

首页xml源码,运用到了FrameLayout组件实现页面动态切换

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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>

bottom部分源码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="@drawable/bottom_bar"
    android:orientation="horizontal"
    android:baselineAligned="false">

    <LinearLayout
        android:id="@+id/id_tab_weixin"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageButton
            android:id="@+id/id_tab_weixin_img"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:contentDescription="@string/app_name"
            android:clickable="false"
            android:src="@drawable/tab_weixin_pressed" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="微信"
            android:clickable="false"
            android:textColor="#ffffff"
            android:textSize="15sp" />
    </LinearLayout>
</LinearLayout>

对点击按钮实现的监听

    private void initFragment(){
   
        fm = getFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.add(R.id.id_content,mTab01);
        transaction.add(R.id.id_content,mTab02);
        t
  • 5
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android Studio实现简易微信程序可以通过以下步骤完成: 1. 创建一个新的Android项目:在Android Studio中点击"File" -> "New" -> "New Project",然后按照向导创建一个新的Android项目。 2. 设计应用的界面:使用Android Studio的布局编辑器来设计微信应用的各个界面,例如聊天界面、联系人界面、发现界面等。可以使用LinearLayout、RelativeLayout等布局来组织界面元素。 3. 创建Fragment:在项目中创建多个Fragment来表示不同的界面。可以通过右键点击项目目录 -> "New" -> "Fragment"来创建Fragment,并在布局文件中定义Fragment的界面。 4. 实现底部导航栏:使用BottomNavigationView或TabLayout来实现底部导航栏,用于切换不同的Fragment。 5. 处理Fragment之间的通信:可以使用接口回调或EventBus等方式来实现Fragment之间的通信,例如在聊天界面点击联系人头像后跳转到联系人界面。 6. 实现聊天功能:使用RecyclerView来显示聊天记录,使用EditText和Button来输入和发送消息。可以使用数据库或网络请求来保存和获取聊天记录。 7. 实现联系人功能:使用RecyclerView来显示联系人列表,可以通过点击联系人列表中的项来跳转到聊天界面。 8. 实现发现功能:可以在发现界面中添加一些功能模块,例如朋友圈、扫一扫等。 9. 运行和测试:在Android Studio中点击"Run"按钮来运行应用程序,并在模拟器或真机上测试应用的各个功能。 10. 调试和优化:根据测试结果进行调试和优化,确保应用程序的稳定性和性能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值