zoukankan      html  css  js  c++  java
  • Notification背景图片问题

    ============问题描述============


    做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============


    引用 楼主 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============


    可以通过代码里面给控件setbackground来试试看。
  • 相关阅读:
    [LeetCode]3Sum Closest
    [LeetCode]3Sum
    [LeetCode]Roman to Integer
    [LeetCode]Integer to Roman
    [LeetCode]Container With Most Water
    [LeetCode]Palindrome Number
    [LeetCode]String to Integer (atoi)
    [LeetCode]Reverse Integer
    Elasticserch与Elasticsearch_dsl用法
    es 查询更新操作
  • 原文地址:https://www.cnblogs.com/lianxu61/p/4046169.html
Copyright © 2011-2022 走看看