Notification背景图片问题

Android 码拜 9年前 (2015-04-26) 1210次浏览 0个评论

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>

Notification背景图片问题
另外我直接在nf.xml设置background就没有问题,但是我的需求是广告图片是弹广告的时候才从网络获取,不能事先放到工程里。

Notification背景图片问题
20分
引用 楼主 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>

Notification背景图片问题
另外我直接在nf.xml设置background就没有问题,但是我的需求是广告图片是弹广告的时候才从网络获取,不能事先放到工程里。

我也不知道,帮你顶一下吧。。。

Notification背景图片问题
10分
你的app在有些设备可以整个填充 是你说的从网络上获取的吗?填充满比如说USB的那个,你去看看系统源码,xml没什么问题,主要是他的图片资源跟我们的不一样
Notification背景图片问题
10分
可以通过代码里面给控件setbackground来试试看。
Notification背景图片问题
引用 3 楼 icyblood198999 的回复:

可以通过代码里面给控件setbackground来试试看。

怎么获取RemoteViews的控件,findViewById不行啊

Notification背景图片问题
仍未解决,先结了吧

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Notification背景图片问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!