一、RemoteViews简介

作用:跨进程更新界面                         使用场景:通知栏、桌面小部件

二、在通知栏上的应用

原理:通过RemoteViews加载布局,通过remoteViews的set方法,载入View动态改变布局

(一)、Notifaction的使用:Notification的使用

(二)、利用RemoteView来自定义布局

步骤①、创建layout布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/show_linear"
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <ImageView
        android:id="@+id/show_iv_icon"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@mipmap/ic_launcher"/>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical">
        <TextView
            android:id="@+id/show_tv_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Hello World"/>
        <TextView
            android:id="@+id/show_tv_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="I am a super man"/>
    </LinearLayout>
</LinearLayout>
notification_show

相关文章:

  • 2021-12-26
  • 2021-12-30
  • 2021-09-19
  • 2022-12-23
  • 2021-10-05
  • 2021-08-31
  • 2022-12-23
  • 2021-10-20
猜你喜欢
  • 2021-12-22
  • 2022-01-09
  • 2021-06-12
  • 2021-08-13
  • 2021-11-17
  • 2022-12-23
  • 2021-08-10
相关资源
相似解决方案