ネイティブ通知ボタンはインタラクティブに使用するのが難しいため、直接変更してください。
異なるモデルのボタンレイアウトの具体的な状況は、ご使用の機器に応じて設定されます。以下は、参考のために、現在の実装プロジェクトのレイアウトです。
frameworks\base\packages\SystemUI\res\layout\status_bar_expanded.xml
<ImageView
android:id="@+id/ic_clear_all_notification"
android:id=layout_width="wrap_content"
android:id=layout_height="wrap_content"
android:id=layout_graviity="center|bottom"
android:layout_marginBottom="25.0dip"
android:scaleType="fitXY"
android:src="@drawable/ic_clear_all_notification"
/>
Javaコードの変更:
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\NotificationPanelView.java
protected void onFinishInflate() {
...
//add for notification clear button
mClearView =(ImageView)findViewById(R.id.ic_clear_all_notification);
mClearView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
mStatusBar.clearAllNotifications();
}
});
//add for notification clear button
}
private void updateNotificationTranslucency() {
float alpha = 1f;
if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp && !mHeadsUpManager.hasPinnedHeadsUp()) {
alpha = getFadeoutAlpha();
}
mNotificationStackScroller.setAlpha(alpha);
//add for notification clear button
KeyguardManager keyguardManager =
(KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
if (keyguardManager.isKeyguardLocked() || mHeadsUpManager.hasPinnedHeadsUp()) {
mClearView.setVisibility(View.INVISIBLE);
} else {
mClearView.setVisibility(ifHasActiveClearableNotifications() ? View.VISIBLE : View.INVISIBLE);
}
//add for notification clear button
}
控制button是否应该显示的关键方法
/**
* Return whether there are any clearable notifications
*/
private boolean ifHasActiveClearableNotifications() {
int childCount = mNotificationStackScroller.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = mNotificationStackScroller.getChildAt(i);
if (!(child instanceof ExpandableNotificationRow)) {
continue;
}
if (((ExpandableNotificationRow) child).canViewBeDismissed()) {
return true;
}
}
return false;
}
移除原生默认的DismissView的显示
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\DismissView.java
protected void onFinishInflate() {
super.onFinishInflate();
mDismissButton = (DismissViewButton) findContentView();
+mDismissButton.setVisibility(View.GONE);
}
小さな記録です。訂正して連絡することを歓迎します。