工程功能介绍

打开app,首先是个闪屏界面(常见于一般打开app时的小广告),设置时间为2s后进入登录界面。在登录界面中,中间可以输入密码,点击登录按钮进入微信的界面。

 

微信的界面由4个fragment组成,第一个fragment用于显示最近收到的信息,第二个fragment用于展示通讯录,该界面用ListView制作而成;第三个是微信的发现界面,第四个fragment用于展示用户的信息。

  

  

消息界面可以通过点击联系人的方式进入聊天界面,并可与向对方发送消息,点击左上方的返回键可以退出聊天界面。

  

第三个fragment,也就是发现界面,因为东西有点多,所以用ScrollView作成可以滚动的布局,通过点击最上面的朋友圈栏,可以进入朋友圈界面查看朋友圈,点击左上角的返回键可以返回至发现页面。

详细代码

代码中涉及到一些图片,如果需要图片文件的话可以在文章底部的工程文件中下载,图片的路径为WechatApplication\app\src\main\res\mipmap-mdpi

另外在实际操作中以这个顺序进行在中途程序可能会被打红线,别管他,代码敲完后大体就没了,或者也可以完全不安这个顺序进行。

闪屏活动

首先我们来创建闪屏活动,先创建他的布局文件。

activity_splash.xml

在layout文件夹中创建新的布局文件,命名为activity_login

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".SplashActivity"><ImageViewandroid:id="@+id/tubiao"android:layout_width="100dp"android:layout_height="100dp"android:src="@mipmap/tubiao"android:layout_marginTop="80dp"android:layout_centerHorizontal="true"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="微信"android:layout_below="@+id/tubiao"android:textSize="50dp"android:textColor="#000000"android:layout_centerHorizontal="true"/>
</RelativeLayout>

SplashActivity

接下来是他的Java类文件,在包内创建新的Java类命名为SplashActivity

public class SplashActivity extends AppCompatActivity {private Handler mHandler = new Handler();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_splash);mHandler.postDelayed(new Runnable() {@Overridepublic void run() {startActivity(new Intent(SplashActivity.this,LoginActivity.class));}},2000);}
}

登录界面

activity_login.xml

在layout文件夹中创建新的布局文件,命名为activity_login

<?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"android:background="#f2f2f2"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><ImageViewandroid:id="@+id/touxiang"android:layout_width="100dp"android:layout_height="100dp"android:background="@mipmap/touxiang"android:layout_centerHorizontal="true"android:layout_marginTop="90dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="所长的肚子"android:layout_below="@+id/touxiang"android:layout_centerHorizontal="true"android:textSize="30dp"android:textColor="#000000"/></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:layout_marginTop="20dp"><TextViewandroid:id="@+id/mima"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密码"android:textSize="30dp"android:textColor="#000000"android:layout_marginTop="5dp"android:layout_marginLeft="20dp"/><EditTextandroid:id="@+id/edittxt"android:layout_width="1040dp"android:layout_height="50dp"android:layout_marginLeft="20dp"android:layout_toRightOf="@+id/mima"android:background="@null"android:hint="请输入密码" /></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><Viewandroid:id="@+id/line"android:layout_width="25dp"android:layout_height="1dp"android:background="#f2f2f2"/><Viewandroid:layout_width="1030dp"android:layout_height="1dp"android:background="#60ff0f"android:layout_toRightOf="@+id/line"/><Viewandroid:layout_width="25dp"android:layout_height="1dp"android:background="#f2f2f2"android:layout_alignParentRight="true"/></RelativeLayout><Buttonandroid:id="@+id/btn_forget_pwd"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/btn_login"android:text="用短信验证码登录"android:textSize="20dp"android:textColor="#2999ce"android:layout_marginLeft="20dp"android:layout_marginTop="10dp"android:background="@null"/><Buttonandroid:id="@+id/btn_login"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="登录"android:textSize="24sp"android:layout_marginTop="10dp"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:background="#f4f5f7"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"><Buttonandroid:id="@+id/dongjie"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="紧急冻结"android:textSize="20dp"android:textColor="#2999ce"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:background="@null"/><TextViewandroid:id="@+id/shuxian1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="|"android:textSize="20dp"android:layout_toLeftOf="@+id/dongjie"android:layout_alignParentBottom="true"android:layout_marginBottom="12dp"/><TextViewandroid:id="@+id/shuxian2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="|"android:textSize="20dp"android:layout_toRightOf="@+id/dongjie"android:layout_alignParentBottom="true"android:layout_marginBottom="12dp"/><Buttonandroid:id="@+id/zhaohui"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="找回密码"android:textSize="20dp"android:textColor="#2999ce"android:layout_alignParentBottom="true"android:layout_toLeftOf="@+id/shuxian1"android:background="@null"/><Buttonandroid:id="@+id/gengduo"android:layout_width="50dp"android:layout_height="wrap_content"android:text="更多"android:textSize="20dp"android:textColor="#2999ce"android:layout_alignParentBottom="true"android:layout_toRightOf="@+id/shuxian2"android:background="@null"/></RelativeLayout>
</LinearLayout>

LoginActivity.java

在包内创建新的Java类命名为LoginActivity

public class LoginActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login);Button button = findViewById(R.id.btn_login);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Intent intent = new Intent(LoginActivity.this,MainActivity.class);startActivity(intent);}});}}

主界面

终于到了主界面了,首先是activity_main

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"><!--内容--><RelativeLayoutandroid:id="@+id/container_content"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="1" /><!--功能菜单--><LinearLayoutandroid:id="@+id/container_menu"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:background="#f2f2f2"android:layout_alignParentBottom="true"><LinearLayoutandroid:id="@+id/menu_weixin"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:gravity="center"android:layout_weight="1"><ImageViewandroid:id="@+id/caidan_weixin"android:layout_width="50dp"android:layout_height="50dp"android:src="@mipmap/weixin02"android:background="@drawable/menu_weixin_icon_selector"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="微信"android:textColor="#000000"android:textSize="20dp"/></LinearLayout><LinearLayoutandroid:id="@+id/menu_tongxunlu"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:gravity="center"android:layout_weight="1"><ImageViewandroid:id="@+id/caidan_tongxun"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/menu_tongxunlu_icon_selector"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="通讯录"android:textColor="#000000"android:textSize="20sp"/></LinearLayout><LinearLayoutandroid:id="@+id/menu_faxian"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:gravity="center"android:layout_weight="1"><ImageViewandroid:id="@+id/caidain_faxian"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/menu_faxian_icon_selector"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="发现"android:textColor="#000000"android:textSize="20sp"/></LinearLayout><LinearLayoutandroid:id="@+id/menu_wode"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"android:gravity="center"android:layout_weight="1"><ImageViewandroid:id="@+id/caidan_wode"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/menu_wode_icon_selector"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="我的"android:textColor="#000000"android:textSize="20sp"/></LinearLayout></LinearLayout></LinearLayout>

第一个fragment,weixin_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="#f2f2f2"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:text="微信"android:textColor="#000000"android:textSize="25dp" /><Buttonandroid:id="@+id/qita"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/qita"android:layout_alignParentRight="true"android:layout_marginTop="15dp"android:layout_marginRight="10dp"/><Buttonandroid:id="@+id/sousuo"android:layout_width="40dp"android:layout_height="40dp"android:layout_marginTop="15dp"android:layout_marginRight="0dp"android:layout_toLeftOf="@+id/qita"android:background="@mipmap/sousuo" /></RelativeLayout><ListViewandroid:id="@+id/weixin_listview"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ffffff"android:divider="#000000"android:overScrollMode="never"/>
</LinearLayout>

第二个fragment,tongxunlu_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="#ffffff"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="#f2f2f2"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:text="通讯录"android:textColor="#000000"android:textSize="25dp" /><Buttonandroid:id="@+id/qita"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/qita"android:layout_alignParentRight="true"android:layout_marginTop="15dp"android:layout_marginRight="10dp"/><Buttonandroid:id="@+id/sousuo"android:layout_width="40dp"android:layout_height="40dp"android:layout_marginTop="15dp"android:layout_marginRight="0dp"android:layout_toLeftOf="@+id/qita"android:background="@mipmap/sousuo" /></RelativeLayout><ListViewandroid:id="@+id/txl_listview"android:layout_width="match_parent"android:layout_height="match_parent"android:divider="#000000"android:overScrollMode="never"/></LinearLayout>

第三个fragment,faxian_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><!--头部--><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="#f2f2f2"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:text="发现"android:textColor="#000000"android:textSize="25dp" /><Buttonandroid:id="@+id/qita"android:layout_width="40dp"android:layout_height="40dp"android:background="@mipmap/qita"android:layout_alignParentRight="true"android:layout_marginTop="15dp"android:layout_marginRight="10dp"/><Buttonandroid:id="@+id/sousuo"android:layout_width="40dp"android:layout_height="40dp"android:layout_marginTop="15dp"android:layout_marginRight="0dp"android:layout_toLeftOf="@+id/qita"android:background="@mipmap/sousuo" /></RelativeLayout><!--内容--><ScrollViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:scrollbars="vertical"android:overScrollMode="never"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><RelativeLayoutandroid:id="@+id/pyquan_click"android:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/pyquan"android:layout_width="30dp"android:layout_height="30dp"android:layout_marginLeft="10dp"android:layout_marginTop="10dp"android:background="@mipmap/pyquan" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"android:layout_toRightOf="@+id/pyquan"android:text="朋友圈"android:textColor="#000000"android:textSize="20dp" /><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:layout_marginTop="10dp"android:layout_marginRight="10dp"android:background="@mipmap/wode_xinxi" /></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/shipinghao"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/shipinghao"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/shipinghao"android:text="视屏号"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="100dp"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/saoysao"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/saoysao"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/saoysao"android:text="扫一扫"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><Viewandroid:layout_width="45dp"android:layout_height="1dp"android:background="#ffffff"/><Viewandroid:layout_width="1000dp"android:layout_height="1dp"android:background="#e0e0e0"/></LinearLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/yyy"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/yaoyyao"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/yyy"android:text="摇一摇"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="100dp"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/kyk"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/kanykan"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/kyk"android:text="看一看"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><Viewandroid:layout_width="45dp"android:layout_height="1dp"android:background="#ffffff"/><Viewandroid:layout_width="1000dp"android:layout_height="1dp"android:background="#e0e0e0"/></LinearLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/sys"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/souysou"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/sys"android:text="搜一搜"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/zbfj"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/zhibofujin"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/zbfj"android:text="直播和附近"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="100dp"android:orientation="vertical"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/gouwu"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/kanykan"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/gouwu"android:text="购物"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><Viewandroid:layout_width="45dp"android:layout_height="1dp"android:background="#ffffff"/><Viewandroid:layout_width="1000dp"android:layout_height="1dp"android:background="#e0e0e0"/></LinearLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/youxi"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/souysou"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/youxi"android:text="游戏"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/xiaochengxu"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/xiaochengxu"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/xiaochengxu"android:text="小程序"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="12dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout></ScrollView></LinearLayout>

第四个fragment,wode_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:background="#f2f2f2"><!--头部--><LinearLayoutandroid:id="@+id/layout_wode_header"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#ffffff"><Buttonandroid:layout_width="100dp"android:layout_height="100dp"android:background="@mipmap/touxiang"android:layout_marginTop="50dp"android:layout_marginLeft="20dp" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="所长的肚子"android:textSize="30dp"android:textColor="#000000"android:layout_marginTop="50dp" /><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="30dp"><TextViewandroid:id="@+id/weixinhao"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="微信号:123456789"android:textSize="20dp"/><Buttonandroid:id="@+id/wode_xinxixinxi"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/wode_xinxi"android:layout_alignParentRight="true"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:src="@mipmap/wode_ma"android:layout_toLeftOf="@+id/wode_xinxixinxi"/></RelativeLayout><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="+状态"android:textSize="20dp"android:background="@null"/></LinearLayout></LinearLayout><Viewandroid:layout_width="wrap_content"android:layout_height="10dp"android:background="#e0e0e0"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/zhifu"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/zhifu"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/zhifu"android:text="支付"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><Viewandroid:layout_width="match_parent"android:layout_height="10dp"android:background="#e0e0e0"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="200dp"android:orientation="vertical"android:background="#ffffff"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"><ImageViewandroid:id="@+id/shoucang"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/shoucang"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/shoucang"android:text="收藏"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"><ImageViewandroid:id="@+id/xiangce"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/xiangce"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/xiangce"android:text="相册"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"><ImageViewandroid:id="@+id/kabao"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/kabao"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/kabao"android:text="卡包"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"><ImageViewandroid:id="@+id/biaoqing"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/biaoqing"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/biaoqing"android:text="表情"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout><Viewandroid:layout_width="wrap_content"android:layout_height="10dp"android:background="#e0e0e0"/><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="50dp"android:background="#ffffff"><ImageViewandroid:id="@+id/shezhi"android:layout_width="30dp"android:layout_height="30dp"android:background="@mipmap/shezhi"android:layout_marginTop="10dp"android:layout_marginLeft="10dp"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_toRightOf="@+id/shezhi"android:text="设置"android:textColor="#000000"android:textSize="20dp"android:layout_marginLeft="5dp"android:layout_marginTop="10dp"/><ImageViewandroid:layout_width="30dp"android:layout_height="30dp"android:layout_alignParentRight="true"android:background="@mipmap/wode_xinxi"android:layout_marginTop="10dp"android:layout_marginRight="10dp"/></RelativeLayout></LinearLayout>

接下来是MainActivity.java

public class MainActivity extends AppCompatActivity implements View.OnClickListener {private LinearLayout mMenuWeixin;private LinearLayout mMenuTongxunlu;private LinearLayout mMenuFaxian;private LinearLayout mMenuWode;private WeixinFragment weixinFragment = new WeixinFragment();private TongxunluFragment tongxunluFragment = new TongxunluFragment();private FaxianFragment faxianFragment = new FaxianFragment();private WodeFragemnt wodeFragemnt = new WodeFragemnt();ImageView weixinImg;ImageView tongxunImg;ImageView faxianImg;ImageView wodeImg;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initView();weixinImg = (ImageView) findViewById(R.id.caidan_weixin);tongxunImg = (ImageView) findViewById(R.id.caidan_tongxun);faxianImg = (ImageView) findViewById(R.id.caidain_faxian);wodeImg = (ImageView) findViewById(R.id.caidan_wode);this.getSupportFragmentManager().beginTransaction().add(R.id.container_content,weixinFragment).add(R.id.container_content,tongxunluFragment).add(R.id.container_content,faxianFragment).add(R.id.container_content,wodeFragemnt).hide(tongxunluFragment).hide(faxianFragment).hide(wodeFragemnt).commit();}private void initView() {mMenuWeixin = this.findViewById(R.id.menu_weixin);mMenuTongxunlu = this.findViewById(R.id.menu_tongxunlu);mMenuFaxian = this.findViewById(R.id.menu_faxian);mMenuWode = this.findViewById(R.id.menu_wode);mMenuWeixin.setOnClickListener(this);mMenuTongxunlu.setOnClickListener(this);mMenuFaxian.setOnClickListener(this);mMenuWode.setOnClickListener(this);}@Overridepublic void onClick(View v){switch (v.getId()){case R.id.menu_weixin:weixinImg.setImageResource(R.mipmap.weixin02);tongxunImg.setImageResource(R.mipmap.tongxunlu01);faxianImg.setImageResource(R.mipmap.faxian01);wodeImg.setImageResource(R.mipmap.wode01);this.getSupportFragmentManager().beginTransaction().show(weixinFragment).hide(tongxunluFragment).hide(faxianFragment).hide(wodeFragemnt).commit();break;case R.id.menu_tongxunlu:weixinImg.setImageResource(R.mipmap.weixin01);tongxunImg.setImageResource(R.mipmap.tongxunlu02);faxianImg.setImageResource(R.mipmap.faxian01);wodeImg.setImageResource(R.mipmap.wode01);this.getSupportFragmentManager().beginTransaction().show(tongxunluFragment).hide(weixinFragment).hide(faxianFragment).hide(wodeFragemnt).commit();break;case R.id.menu_faxian:weixinImg.setImageResource(R.mipmap.weixin01);tongxunImg.setImageResource(R.mipmap.tongxunlu01);faxianImg.setImageResource(R.mipmap.faxian02);wodeImg.setImageResource(R.mipmap.wode01);this.getSupportFragmentManager().beginTransaction().show(faxianFragment).hide(weixinFragment).hide(tongxunluFragment).hide(wodeFragemnt).commit();break;case R.id.menu_wode:weixinImg.setImageResource(R.mipmap.weixin01);tongxunImg.setImageResource(R.mipmap.tongxunlu01);faxianImg.setImageResource(R.mipmap.faxian01);wodeImg.setImageResource(R.mipmap.wode02);this.getSupportFragmentManager().beginTransaction().show(wodeFragemnt).hide(tongxunluFragment).hide(faxianFragment).hide(weixinFragment).commit();break;default:break;}}
}

下一篇

至此制作已完成了一大半,接下来留到下一篇文章

Android Studio 制作微信界面 下_nazonomaster的博客-CSDN博客https://blog.csdn.net/nazonomaster/article/details/124463933

Android Studio 制作微信界面 上相关推荐

  1. Android Studio 制作微信界面 下

    主界面 上一篇文章的链接: Android Studio 制作微信界面 上_nazonomaster的博客-CSDN博客https://blog.csdn.net/nazonomaster/artic ...

  2. android studio微信界面设计,android studio开发微信界面

    android studio开发微信界面 android studio开发微信界面 功能说明:主要是做微信的简单的聊天界面,利用Fragment,进行微信界面的跳转 项目代码: 源代码地址 MainA ...

  3. Android Studio——类微信界面设计

    设计目标:Android studio制作简易类微信界面. 功能:展示四个可切换界面,当点击下方按钮时,界面随之切换. 布局:顶部和底部layout.主页面(中间放一个framelayout显示界面内 ...

  4. Android Studio 类微信界面的制作

    设计目标 使用Android Studio完成类微信的门户页面框架设计,APP包含4个tab页面.框架设计使用fragment,activity. 功能说明 界面的样式和微信打开后的界面相似 1点击底 ...

  5. 安卓移动开发实验:Android Studio设计微信界面

    一.实验的目的 通过使用Android Studio的Fragment和layout,来实现简单的微信界面切换. 二.app的功能 能够通过应用底部的bottom来实现四个页面的来回切换. 三.实验过 ...

  6. android studio开发微信界面

    微信界面 主要是做微信的简单的聊天界面,利用Fragment,进行微信界面的跳转 项目代码: 源代码 微信界面 图片: 这是我们要做的界面主要分为头部(top.xml)文件,底部(bottom.xml ...

  7. Android Studio类微信界面设计

    文章目录 一.类微信界面能实现的功能 二.xml代码 top.xml bottom.xml tab.xml activity_main.xml 三.Java代码 MainActivity.java w ...

  8. Android Studio制作手机App:通过手机蓝牙(Bluetooth)与STM32上的低功耗蓝牙(HC-42)连接通信,实现手机端对单片机的控制。

    背景: 本文的内容是针对单片机蓝牙模块(HC-42)开发的手机App.在这之前,我想先声明一点,手机与手机间的蓝牙连接方式"与"手机与HC间的蓝牙连接方式"是不一样的.原 ...

  9. Android Studio 开发–微信APP门户界面设计

    Android Studio 开发–微信APP门户界面设计 本次Github代码仓库 --crcr1013/MyWechat 文章目录 Android Studio 开发--微信APP门户界面设计 前 ...

最新文章

  1. 10w 行级别数据的 Excel 导入优化记录
  2. php isset()与empty()详解
  3. ndpi 流量协议分析
  4. LeetCode - 28. Implement strStr()
  5. 聊聊我对开发项目选技术的看法
  6. selenium的简单介绍
  7. wps 模拟分析 规划求解_FFU气流仿真模拟,到底有多简单?
  8. mysql 字段 中文_如何配置mysql支持中文字段名与中文字段
  9. 面向对象—的__new__()方法详解
  10. html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项
  11. 腾讯优图CVPR中标论文:不靠硬件靠算法,暗光拍照也清晰
  12. Zabbix Agent端配置文件说明
  13. XBMC源代码分析 7:视频播放器(dvdplayer)-输入流(以libRTMP为例)
  14. 知也atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException  v2 q31无涯 - I...
  15. vb.net使用DirectX入门知识
  16. Ruby / Rails代码气味基础01
  17. 如何获取量化交易历史复权数据?
  18. 新手小白如何挑选吉他,附几款超高性价比吉他推荐
  19. python画立体的心_在python3中绘制三维多边形
  20. [转载]【苹果千层派】轻松玩转酥皮_万金油_新浪博客

热门文章

  1. eclipse资源文件搜索如何去掉class文件
  2. 与日历有关的小程序推荐
  3. C# mschart 控件 框选 删除部分数据 及游标CursorX CursorY 使用
  4. 在Excel中选取一行中的最大数值进行标题匹配
  5. LaTeX写一份完整的物理实验报告
  6. boonton 功率测试软件,Power Tester
  7. 印象笔记的使用技巧总结
  8. scratch连接wedo2.0超详细教程(附资源)
  9. 一行代码去除序列中含有n或者其他简并碱基的低质量序列
  10. html点击按钮弹出悬浮窗_点击文字或按钮弹出一个DIV窗口(DIV悬浮窗口)