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来试试看。
相关文章
相关标签/搜索