Notification背景圖片問題

============問題描述============java


作Notification純圖片廣告的時候,出現廣告圖片不能填充整個Notification,兩邊有空隙。這個圖片是反編譯別人的應用獲得的,他的應用能夠,我本身的就不行。測試了幾個設備,有的能夠有的不行,而別人的應用均可以兼容。因爲他的代碼作了混淆,也不知道他是怎麼實現的。
我本身的關鍵代碼以下:
RemoteViews mRemoteViews = new RemoteViews(this.getPackageName(), R.layout.nf);

		Bitmap bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/Download/1.jpg");//設置廣告圖片

		mRemoteViews.setImageViewBitmap(R.id.img_bg, bm);

nf.xml以下:
<?xml version="1.0" encoding="utf-8"?>

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/img_bg"

    android:layout_width="match_parent"

    android:layout_height="match_parent" >

</ImageView>


另外我直接在nf.xml設置background就沒有問題,可是個人需求是廣告圖片是彈廣告的時候才從網絡獲取,不能事先放到工程裏。

============解決方案1============android


引用 樓主 kingyang123 的回覆:
作Notification純圖片廣告的時候,出現廣告圖片不能填充整個Notification,兩邊有空隙。這個圖片是反編譯別人的應用獲得的,他的應用能夠,我本身的就不行。測試了幾個設備,有的能夠有的不行,而別人的應用均可以兼容。因爲他的代碼作了混淆,也不知道他是怎麼實現的。
我本身的關鍵代碼以下:
RemoteViews mRemoteViews = new RemoteViews(this.getPackageName(), R.layout.nf);

		Bitmap bm = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/Download/1.jpg");//設置廣告圖片

		mRemoteViews.setImageViewBitmap(R.id.img_bg, bm);

nf.xml以下:
<?xml version="1.0" encoding="utf-8"?>

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/img_bg"

    android:layout_width="match_parent"

    android:layout_height="match_parent" >

</ImageView>


另外我直接在nf.xml設置background就沒有問題,可是個人需求是廣告圖片是彈廣告的時候才從網絡獲取,不能事先放到工程裏。
我也不知道,幫你頂一下吧。。。

============解決方案2============網絡


你的app在有些設備能夠整個填充 是你說的從網絡上獲取的嗎?填充滿好比說USB的那個,你去看看系統源碼,xml沒什麼問題,主要是他的圖片資源跟咱們的不同

============解決方案3============app

能夠經過代碼裏面給控件setbackground來試試看。
相關文章
相關標籤/搜索