android studio实现类微信界面
一.基本框架
1.顶部top栏的实现
顶部的实现过程:最外层为水平的LinearLayout,在其下添加一个TextView。
如图:
代码如下:
<?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">
<TextView
android:id="@+id/textView_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple_200"
android:gravity="center"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/weixin"
android:textSize="19dp" />
</LinearLayout>
实现效果如图:
2.底部tab栏的实现
底部需要四个部分,每个部分包括一个imageview和textview,imageview要在textview上方。
如图:
代码如下:
<?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:paddingTop="10dp"
android:background="@color/tabcolor"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="40dp"
app:srcCompat="@drawable/wxh" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/weixin" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="40dp"
app:srcCompat="@drawable/tongxunluhui" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/tongxunlu" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="40dp"
app:srcCompat="@drawable/faxianhui" />
<TextView
android:id="@+id/textView3"
android:layout_width="m