最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android實(shí)現(xiàn)常駐通知欄遇到的問(wèn)題及解決辦法

 更新時(shí)間:2020年06月30日 16:49:16   作者:唐人小調(diào)  
這篇文章主要介紹了android實(shí)現(xiàn)常駐通知欄遇到的問(wèn)題及解決辦法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

實(shí)現(xiàn)常駐通知欄時(shí)遇到的問(wèn)題:

無(wú)論如何就是不顯示通知,查看日志發(fā)現(xiàn)貌似報(bào)錯(cuò)了:

2020-06-28 14:11:34.923 6387-6387/xxx E/CrashReport: android.app.RemoteServiceException: Bad notification posted from package xxx: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:192)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)

說(shuō)的是布局報(bào)錯(cuò),所使用的布局如下:

 根據(jù)報(bào)錯(cuò)信息來(lái)看,就是這個(gè)

android.support.constraint.ConstraintLayout

的問(wèn)題了。

然后將布局的根view修改為RelativeLayout。

運(yùn)行,報(bào)錯(cuò),,,,納尼?

2020-06-28 14:24:02.622 11436-11436/xxx E/CrashReport: android.app.RemoteServiceException: Bad notification posted from package xxx: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_height attribute.
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:192)
        at android.app.ActivityThread.main(ActivityThread.java:6815)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)

雖然繼續(xù)報(bào)錯(cuò),但是發(fā)現(xiàn)跟第一次報(bào)的錯(cuò)不同了,說(shuō)明第一個(gè)報(bào)錯(cuò)問(wèn)題解決。

那么來(lái)細(xì)看第二個(gè)報(bào)錯(cuò)信息:

Binary XML file line #2: You must supply a layout_height attribute.

看信息是說(shuō)布局中缺少layout_height屬性,但是確認(rèn)布局中設(shè)置了這屬性啊。。。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="@dimen/dp_74"
  android:background="@drawable/shape_bg_resident_notify">
 
 <ImageView
   android:id="@+id/iv_resident_weather"
   android:layout_width="@dimen/dp_45"
   android:layout_height="@dimen/dp_45"
   android:layout_marginStart="@dimen/dp_10"
   android:background="@mipmap/weather_icon_blue_big_cloudy"
   android:layout_centerVertical="true"/>
 
 <TextView
   android:id="@+id/tv_resident_weather_temp"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="28"
   android:textSize="@dimen/sp_40"
   android:textColor="#ff333333"
   android:layout_toEndOf="@+id/iv_resident_weather"
   android:layout_centerVertical="true"
   android:layout_marginStart="@dimen/dp_5"/>
 
 <TextView
   android:id="@+id/tv_resident_degree"
   android:layout_width="@dimen/dp_6"
   android:layout_height="@dimen/dp_6"
   android:layout_marginStart="@dimen/dp_3"
   android:layout_marginTop="@dimen/dp_24"
   android:layout_toEndOf="@+id/tv_resident_weather_temp"
   android:background="@drawable/shape_resident_weather_temp"/>
 
 <TextView
   android:id="@+id/tv_resident_weather_cond"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="多云轉(zhuǎn)晴"
   android:textSize="@dimen/sp_16"
   android:textColor="@color/color_333333"
   android:layout_marginTop="@dimen/dp_14"
   android:layout_marginStart="@dimen/dp_6"
   android:layout_toEndOf="@+id/tv_resident_degree" />
 
 <TextView
   android:id="@+id/tv_resident_temp_range"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="21~34℃"
   android:textColor="@color/color_333333"
   android:textSize="@dimen/sp_16"
   android:layout_marginTop="@dimen/dp_5"
   android:layout_below="@+id/tv_resident_weather_cond"
   android:layout_toEndOf="@+id/tv_resident_degree"
   android:layout_marginStart="@dimen/dp_6"/>
 
 <TextView
   android:id="@+id/tv_resident_aqi"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="空氣優(yōu)"
   android:textSize="@dimen/sp_16"
   android:textColor="@color/color_333333"
   android:layout_alignParentEnd="true"
   android:layout_marginTop="14dp"
   android:layout_marginEnd="@dimen/dp_10"/>
 
 <ImageView
   android:id="@+id/iv_resident_aqi"
   android:layout_width="@dimen/dp_18"
   android:layout_height="@dimen/dp_18"
   android:src="@drawable/ic_icon_aqi"
   android:layout_toStartOf="@+id/tv_resident_aqi"
   android:layout_marginEnd="@dimen/dp_5"
   android:layout_marginTop="@dimen/dp_16"/>
 
 <TextView
   android:id="@+id/tv_resident_desc"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="浦東新區(qū) 14:33發(fā)布"
   android:textSize="@dimen/sp_12"
   android:textColor="@color/color_999999"
   android:layout_marginEnd="@dimen/dp_10"
   android:layout_alignParentEnd="true"
   android:layout_below="@+id/tv_resident_aqi"
   android:layout_marginTop="@dimen/dp_11"/>
 
</RelativeLayout>

莫名奇妙啊簡(jiǎn)直

然后仔細(xì)想想可能的原因:難不成是因?yàn)榉直媛蔬m配的問(wèn)題?

就是沒(méi)有匹配到合適的分辨率的尺寸。那就試一下,把布局中所有引用@dimen的地方直接改為使用尺寸。

運(yùn)行,成功?。?!

問(wèn)題:發(fā)現(xiàn)有個(gè)布局上的問(wèn)題

自定義通知欄設(shè)置了背景,寬度是match_parent,但是發(fā)現(xiàn)在某些手機(jī)上,如小米6(截圖所示),可以看到寬度竟然沒(méi)有充滿全屏。

但是在華為, vivo等手機(jī)上正常。

那就把這個(gè)背景去掉,自適應(yīng)好了。

總結(jié)

到此這篇關(guān)于android實(shí)現(xiàn)常駐通知欄遇到的問(wèn)題及解決辦法的文章就介紹到這了,更多相關(guān)android 常駐通知欄內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android自定義Toolbar使用方法詳解

    Android自定義Toolbar使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Android自定義Toolbar使用方法 ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • Android利用Sensor實(shí)現(xiàn)傳感器功能

    Android利用Sensor實(shí)現(xiàn)傳感器功能

    這篇文章主要為大家詳細(xì)介紹了Android利用Sensor實(shí)現(xiàn)傳感器功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • 淺談Android App開(kāi)發(fā)中Fragment的創(chuàng)建與生命周期

    淺談Android App開(kāi)發(fā)中Fragment的創(chuàng)建與生命周期

    這篇文章主要介紹了Android App開(kāi)發(fā)中Fragment的創(chuàng)建與生命周期,文中詳細(xì)地介紹了Fragment的概念以及一些常用的生命周期控制方法,需要的朋友可以參考下
    2016-02-02
  • 基于Android實(shí)現(xiàn)顏色漸變動(dòng)畫(huà)效果

    基于Android實(shí)現(xiàn)顏色漸變動(dòng)畫(huà)效果

    本文主要給大家介紹了Android實(shí)現(xiàn)顏色漸變動(dòng)畫(huà)效果,實(shí)現(xiàn)這樣的一個(gè)動(dòng)畫(huà)漸變的效果很簡(jiǎn)單,只需要兩步,第一步用GradientDrawable實(shí)現(xiàn)兩個(gè)顏色之間的漸變效果,第二步用屬性動(dòng)畫(huà)實(shí)現(xiàn)顏色變化的過(guò)程,需要的朋友可以參考下
    2024-01-01
  • Android?側(cè)滑按鈕的實(shí)現(xiàn)代碼

    Android?側(cè)滑按鈕的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Android?側(cè)滑按鈕的實(shí)現(xiàn),本文結(jié)合示例代碼圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • Android給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法

    Android給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法

    下面小編就為大家?guī)?lái)一篇Android給TextView添加點(diǎn)擊事件的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-12-12
  • 基于Android實(shí)現(xiàn)3D翻頁(yè)效果

    基于Android實(shí)現(xiàn)3D翻頁(yè)效果

    這篇文章主要為大家詳細(xì)介紹了基于Android實(shí)現(xiàn)3D翻頁(yè)效果的具體代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • Android中的Coroutine協(xié)程原理解析

    Android中的Coroutine協(xié)程原理解析

    這篇文章主要介紹了Android中的Coroutine協(xié)程原理解析,本文將會(huì)圍繞掛起與恢復(fù)徹底剖析協(xié)程的實(shí)現(xiàn)原理,包括Kotlin函數(shù)基礎(chǔ)知識(shí)復(fù)習(xí),關(guān)于函數(shù)的個(gè)人經(jīng)驗(yàn)總結(jié),需要的朋友可以參考下
    2022-03-03
  • Android基于OpenGL在GLSurfaceView上繪制三角形及使用投影和相機(jī)視圖方法示例

    Android基于OpenGL在GLSurfaceView上繪制三角形及使用投影和相機(jī)視圖方法示例

    這篇文章主要介紹了Android基于OpenGL在GLSurfaceView上繪制三角形及使用投影和相機(jī)視圖方法,結(jié)合實(shí)例形式分析了Android基于OpenGL的圖形繪制技巧,需要的朋友可以參考下
    2016-10-10
  • Android判斷網(wǎng)絡(luò)類型的方法(2g,3g還是wifi)

    Android判斷網(wǎng)絡(luò)類型的方法(2g,3g還是wifi)

    這篇文章主要介紹了Android判斷網(wǎng)絡(luò)類型的方法,可實(shí)現(xiàn)判斷2g,3g還是wifi的功能,結(jié)合實(shí)例形式分析了Android針對(duì)網(wǎng)絡(luò)類型的相關(guān)判定技巧,需要的朋友可以參考下
    2016-02-02

最新評(píng)論

石林| 博湖县| 邵武市| 额敏县| 大英县| 淳安县| 余干县| 上犹县| 绍兴县| 商都县| 库尔勒市| 泗洪县| 黎川县| 浦城县| 福安市| 乌兰察布市| 牡丹江市| 兴和县| 陕西省| 大安市| 依兰县| 靖江市| 托里县| 上林县| 贵定县| 珠海市| 新巴尔虎右旗| 元氏县| 互助| 大竹县| 浙江省| 乌鲁木齐市| 三台县| 凌源市| 洪雅县| 土默特左旗| 崇礼县| 平和县| 漾濞| 方山县| 洪湖市|