QMUI框架使用总结

安卓框架

Posted by MetaNetworks on October 24, 2019
本页面总访问量

用了大概几个月的QMUI框架,总结一下,慢慢更新

状态栏沉浸

  1. TopBar XML文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
     <?xml version="1.0" encoding="utf-8"?>
     <com.qmuiteam.qmui.widget.QMUIWindowInsetLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:fitsSystemWindows="true">
         <com.qmuiteam.qmui.widget.QMUINotchConsumeLayout
             android:id="@+id/not_safe_bg"
             android:layout_width="match_parent"
             android:layout_height="match_parent">
        
             <com.qmuiteam.qmui.widget.QMUITopBarLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:id="@+id/topbar"
                 app:qmui_topbar_bg_color="@color/app_main"
                 />
         </com.qmuiteam.qmui.widget.QMUINotchConsumeLayout>
     </com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
        
    
  2. Activity XML文件

    • 不需要fitsSystemWindows
    • background设置为导航栏颜色
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
     <?xml version="1.0" encoding="utf-8"?>
     <com.qmuiteam.qmui.layout.QMUILinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:tools="http://schemas.android.com/tools"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         tools:context=".main.MainActivity"
         android:background="@color/app_main" <---关键代码
         android:orientation="vertical">
        
         <include layout="@layout/item_topbar"/>
        
         <com.qmuiteam.qmui.layout.QMUILinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:orientation="vertical"
             android:background="@color/qmui_config_color_white">
        
             <-->你的文件</-->
        
         </com.qmuiteam.qmui.layout.QMUILinearLayout>
        
     </com.qmuiteam.qmui.layout.QMUILinearLayout>