SystemUI 显示通知布局文件详解

1.View层级图:

 2.View属性:

Type(Id)widthheightmargnlayout_gravityvisibilityspecial
topbottom
StatusBarWindowViewmatch_parentmatch_parent    fitsSystemWindows="true"
NotificationPanelView(notification_panel)match_parentmatch_parent   gonebackground="@android:color/transparent"
NotificationsQuickSettingsContainer(notification_container_parent)match_parentmatch_parent  fill_horizontal|top  
NotificationStackScrollLayout(notification_stack_scroller)match_parentmatch_parent0dp32dpfill_horizontal|top importantForAccessibility="no"

 属性简单介绍:

  • StatusBarWindowView                                                                            SystemUI的根布局
  • NotificationPanelView(notification_panel)                                                SystemUI下来界面的根布局,默认隐藏,接收到下拉操作后显示
  • NotificationsQuickSettingsContainer(notification_container_parent)        快捷设置布局,包含通知,跨界设置按钮 亮度进度条等
  • NotificationStackScrollLayout(notification_stack_scroller)                        通知的根布局

3.特殊设置介绍:

在NotificationStackScrollLayout和NotificationsQuickSettingsContainer有一个特殊设置的写法

32    <com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
33        android:layout_width="match_parent"
34        android:layout_height="match_parent"
35        android:layout_gravity="@integer/notification_panel_layout_gravity"
36        android:id="@+id/notification_container_parent"
37        android:clipToPadding="false"
38        android:clipChildren="false">

在上面android:layout_gravity="@integer/notification_panel_layout_gravity"这种写法很少见但是属于正常设置,在dimen.xml中设置<integer>标签,使用integer值来具体设置layout位置,这个是根据常量定义的具体值来使用的。若熟悉APK反编译。可以看到xml文件反编译后所有的等号后的值都会使用常量的具体值来替换,例如:

32    <com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
33        android:layout_width="-1"
34        android:layout_height="-1"
35        android:layout_gravity="49"

在dimen.xml中@integer/notification_panel_layout_gravity具体定义如下:

<!-- Gravity for the notification panel -->
    <integer name="standard_notification_panel_layout_gravity">0x31</integer><!-- top|center_horizontal -->
    <integer name="notification_panel_layout_gravity">0x37</integer><!-- fill_horizontal|top -->

在源码中截取一些常用的常量值:

/**
 * This view will adjust its padding to fit sytem windows (e.g. status bar)
 */
private static final int FITS_SYSTEM_WINDOWS = 0x00000002;

/**
 * This view is visible.
 * Use with {@link #setVisibility} and <a href="#attr_android:visibility">{@code
 * android:visibility}.
 */
public static final int VISIBLE = 0x00000000;

/**
 * This view is invisible, but it still takes up space for layout purposes.
 * Use with {@link #setVisibility} and <a href="#attr_android:visibility">{@code
 * android:visibility}.
 */
public static final int INVISIBLE = 0x00000004;

/**
 * This view is invisible, and it doesn't take any space for layout
 * purposes. Use with {@link #setVisibility} and <a href="#attr_android:visibility">{@code
 * android:visibility}.
 */
public static final int GONE = 0x00000008;


/**
 * This view does not want keystrokes.
 * <p>
 * Use with {@link #setFocusable(int)} and <a href="#attr_android:focusable">{@code
 * android:focusable}.
 */
public static final int NOT_FOCUSABLE = 0x00000000;

/**
 * This view wants keystrokes.
 * <p>
 * Use with {@link #setFocusable(int)} and <a href="#attr_android:focusable">{@code
 * android:focusable}.
 */
public static final int FOCUSABLE = 0x00000001;

/**
 * This view determines focusability automatically. This is the default.
 * <p>
 * Use with {@link #setFocusable(int)} and <a href="#attr_android:focusable">{@code
 * android:focusable}.
 */
public static final int FOCUSABLE_AUTO = 0x00000010;

/**
 * <p>Indicates this view can be clicked. When clickable, a View reacts
 * to clicks by notifying the OnClickListener.<p>
 * {@hide}
 */
static final int CLICKABLE = 0x00004000;

/**
 * <p>Indicates this view can take / keep focus when int touch mode.</p>
 * {@hide}
 */
static final int FOCUSABLE_IN_TOUCH_MODE = 0x00040000;

/**
 * <p>
 * Indicates this view can be long clicked. When long clickable, a View
 * reacts to long clicks by notifying the OnLongClickListener or showing a
 * context menu.
 * </p>
 * {@hide}
 */
static final int LONG_CLICKABLE = 0x00200000;

/**
 * View flag indicating that the screen should remain on while the
 * window containing this view is visible to the user.  This effectively
 * takes care of automatically setting the WindowManager's
 * {@link WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON}.
 */
public static final int KEEP_SCREEN_ON = 0x04000000;

/**
 * View flag indicating whether {@link #addFocusables(ArrayList, int, int)}
 * should add only Views focusable in touch mode.
 */
public static final int FOCUSABLES_TOUCH_MODE = 0x00000001;


简单列了一些,详细可参考源码:

http://androidxref.com/8.1.0_r33/xref/frameworks/base/core/java/android/view/View.java

欢迎斧正!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值