亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:36日期:2022-09-23 14:04:22

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

無論如何就是不顯示通知,查看日志發(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.ConstraintLayoutat 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)

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

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

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

android.support.constraint.ConstraintLayout

的問題了。

然后將布局的根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ò)不同了,說明第一個(gè)報(bào)錯(cuò)問題解決。

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

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

看信息是說布局中缺少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: 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: 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: 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: 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: 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: 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: android:layout_width='@dimen/dp_18' android:layout_height='@dimen/dp_18' android:src='http://www.aoyou183.cn/bcjs/@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: 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配的問題?

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

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

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

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

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

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

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

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

總結(jié)

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

標(biāo)簽: Android
相關(guān)文章:
主站蜘蛛池模板: 天天摸夜夜添久久精品麻豆 | 国产无套在线观看视频 | 国内欧美一区二区三区 | 欧洲精品视频在线观看 | 欧美日韩中文国产一区 | 欧美a级v片在线观看一区 | 欧美爱爱小视频 | 含羞草麻豆 | 成人精品一区二区www | 国产 欧美 日产久久 | 青青操手机看 | 伊人久久大杳蕉综合大象 | www国产精品 | 性欧美高清理论片 | gogo大胆全球裸xxxx图片 | 国产成人免费片在线观看 | 777成了人精品视频 777色淫网站女女 | 在线观看一区二区三区视频 | 国产精品不卡在线 | 一级成人毛片免费观看欧美 | 亚洲 欧美 日韩中文字幕一区二区 | 黄色网页在线免费观看 | 免费在线观看黄色的网站 | 激性欧美激情在线aa | 国产日韩精品视频一区二区三区 | 在线观看精品国内福利视频 | 国产一区二区在线播放 | 青青伊人久久 | 欧美一级成人免费大片 | 久久免费精品视频在线观看 | 欧美操美女 | 亚洲精品91在线 | 日本三级免费片 | 国产乱人伦精品一区二区 | 黄色aa视频 | 最新国语露脸精品国产 | 日本美女视频韩国视频网站免费 | 性欧美成人免费观看视 | 欧美成a人片在线观看久 | 青娱乐91视频 | 五月婷婷综合基地 |