Interface design
(1) After creating the new project, create.xml files, respectively top and bottom files, and insert plug-ins into them to modify their properties. The following is an example of the TOP control:
<? The 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="65dp" android:gravity="center" android:background="#000000" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_weight="1" android:text="WeChat" android:textColor="#ffffff" android:textSize="40sp" /> </LinearLayout>Copy the code
The following is an example of the BOTTOM control:
<LinearLayout android:layout_width="0dp" android:layout_height="100dp" android:layout_weight="1" android:background="@color/black" android:orientation="vertical"> <ImageButton android:id="@+id/id_tab_WeChat_img" android:layout_width="match_parent" android:layout_height="63dp" android:background="#000000" android:clickable="false" app:srcCompat="@android:drawable/ic_dialog_email" /> <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" Android :gravity=" # FFFFFF "Android :gravity=" horizontal" Android :gravity=" gravity" Android :saveEnabled="false" Android :text="微信" Android :textColor="# FFFFFF" android:textSize="20sp" /> </LinearLayout>Copy the code
The bottom and top results are as follows:
Insert a Framelayout control into the activity_main. XML file and edit the code
<? The 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="match_parent" android:layout_weight="1"> </FrameLayout> <include layout="@layout/bottom" /> </LinearLayout>Copy the code
The following interface can be obtained:
Listening to the control
Create four XML files in Layout, tab01, TAB02,tab03,tab04, and add a TextView to each file with the content “Here is wechat/Friends/Contacts/Settings interface”. Then create four Fragment files in the Java folder: WeChatBlankFragment, FrdBlankFragment, ContactBlankFragment, and SettingsBlankFragment. Then write the function in the MainActivity file, and finally run the result as shown below:
Gitee Warehouse: gitee.com/gonnainsane…