How to add vertical line to RemoteView for custom Android Notifications?

后端 未结 2 342
广开言路
广开言路 2021-01-14 07:57

I\'m struggling to add a vertical line to a custom Android Notification. I\'ve tried adding a view like this to my Relative Layout:



        
相关标签:
2条回答
  • 2021-01-14 08:41

    You can't inflate just any view in a RemoteView. Change your View to an empty TextView or ImageView.

    A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

    FrameLayout
    LinearLayout
    RelativeLayout
    

    And the following widget classes:

    AnalogClock
    Button
    Chronometer
    ImageButton
    ImageView
    ProgressBar
    TextView
    ViewFlipper
    ListView
    GridView
    StackView
    AdapterViewFlipper
    

    Descendants of these classes are not supported.

    Reference: http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

    0 讨论(0)
  • 2021-01-14 08:45
        <LinearLayout
            android:layout_width="1dp"
            android:layout_height="25dp"
            android:layout_gravity="center_vertical"
            android:alpha="0.3"
            android:background="#FFFFFF" />
    

    We have to add like this.

    0 讨论(0)
提交回复
热议问题