微信简单界面

一.top和bottom

1.top

需要一个linearlayout和一个text View

2.bottom

需要的控件以及呈现效果如下图所示:
在这里插入图片描述
这里给出一个LineaLayout示例代码:

<LinearLayout
        android:id="@+id/LinearLayout_wexin"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            app:srcCompat="@android:drawable/btn_star" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:clickable="false"
            android:gravity="center"
            android:text="聊天"
            android:textSize="24sp" />

    </LinearLayout>

二.创建四个Fragment,分别对应“聊天”、“联系人”、“朋友圈”、“我的”这四个xml文件

其中wexinFragment函数如下:

package com.example.wechat;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/*
 * A simple {@link Fragment} subclass.
 * Use the {@link wexinFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class wexinFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_wexin, container, false);
    }
}

各个java文件及Fragment文件如下:
在这里插入图片描述
以下是mainactivity函数,具体的函数定义见最后面的链接

public class MainActivity extends AppCompatActivity  {
    private Fragment wexinFragment=new wexinFragment();
    private Fragment myFragment=new myFragment();
    private Fragment worldFragment=new worldFragment();
    private Fragment friendFragment=new friendFragment();
    private FragmentManager fm;
    private LinearLayout linearLayout1,linearLayout2,linearLayout3,linearLayout4;
    private TextView textView1,textView2,textView3,textView4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        linearLayout1 = findViewById(R.id.LinearLayout_wexin);
        linearLayout2 = findViewById(R.id.LinearLayout_friend);
        linearLayout3 = findViewById(R.id.LinearLayout_world);
        linearLayout4 = findViewById(R.id.LinearLayout_my);
        linearLayout1.setOnClickListener(this::onClick);
        linearLayout2.setOnClickListener(this::onClick);
        linearLayout3.setOnClickListener(this::onClick);
        linearLayout4.setOnClickListener(this::onClick);
        initFragment();
        showfragment(0);
    }

三.最后效果图:

在这里插入图片描述

四.我的gitee库: https://gitee.com/jiang-zhongwen/jiang-zhongwen.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值