我正在使用新的 Notification.MediaStyle 类向 FTP 流式音乐播放器应用程序实现 Lollipop 风格的通知。我将专辑封面设置为我的“大图标”。
鉴于专辑封面直接取自当前正在播放的文件,专辑封面的大小因来源而异(可能高达 5000x5000)。
从我的 pre-lollipop 代码中,我在以下定义的最大尺寸下解码位图:
android.R.dimen.notification_large_icon_width
和
android.R.dimen.notification_large_icon_height
效果很好,因为解码时间更快,内存使用也很理想。
但是,当此代码应用于我的 MediaStyle 样式时,展开 View 使用的图标比尺寸参数定义的图标大得多,导致展开时专辑封面模糊。
是否有一些常量来定义 MediaStyle 大图标的展开 View 的最大尺寸?或者这个问题有一些解决方法吗?按照目前的情况,以全分辨率解码艺术作品是 Not Acceptable ,因为这可能会导致应用程序因 OOM 而崩溃。
最佳答案
从 Lollipop 源代码我可以看到图像大小是 128dp,参见 notification_template_material_big_media.xml on GitHub :
<!-- Layout to be used with only max 3 actions. It has a much larger picture at the left side-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="#00000000"
android:tag="bigMediaNarrow"
>
<ImageView android:id="@+id/icon"
android:layout_width="128dp"
android:layout_height="128dp"
android:scaleType="centerCrop"
/>
<!-- ...Nothing interesting for us futher... -->
</RelativeLayout>
这适用于具有 3 个或更少操作按钮的扩展布局。期待Notification.MediaStyle.getBigLayoutResource(int) on GrepCode ,如果有更多的按钮似乎notification_template_material_big_media.xml使用:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="#00000000"
android:tag="bigMedia"
>
<include layout="@layout/notification_template_icon_group"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
/>
<!-- ...Nothing interesting for us futher... -->
</RelativeLayout>
和notification_template_icon_group.xml看起来像这样:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
android:id="@+id/icon_group"
>
<ImageView android:id="@+id/icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:scaleType="centerInside"
/>
<ImageView android:id="@+id/right_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:padding="3dp"
android:layout_gravity="end|bottom"
android:scaleType="centerInside"
android:visibility="gone"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
/>
</FrameLayout>
您可以在 .../res/values/dimens.xml 中找到 notification_large_icon_width 和 notification_large_icon_height :
<!-- The width of the big icons in notifications. -->
<dimen name="notification_large_icon_width">64dp</dimen>
<!-- The width of the big icons in notifications. -->
<dimen name="notification_large_icon_height">64dp</dimen>
所以最终答案 - 128dp 用于带有 3 个或更少操作按钮的扩展布局,如果有超过 3 个则为 64dp。
关于android - MediaStyle LargeIcon 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27984766/
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
Region是HBase数据管理的基本单位,region有一点像关系型数据的分区。region中存储这用户的真实数据,而为了管理这些数据,HBase使用了RegionSever来管理region。Region的结构hbaseregion的大小设置默认情况下,每个Table起初只有一个Region,随着数据的不断写入,Region会自动进行拆分。刚拆分时,两个子Region都位于当前的RegionServer,但处于负载均衡的考虑,HMaster有可能会将某个Region转移给其他的RegionServer。RegionSplit时机:当1个region中的某个Store下所有StoreFile
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我在一段非常简单的代码(如我所想)中得到了一个错误的值:org=4caseorgwhenorg=4val='H'endputsval=>nil请不要生气,我希望我错过了一些非常明显的东西,但我真的想不通。谢谢。 最佳答案 这是典型的Ruby错误。case有两种被调用的方法,一种是你传递一个东西作为分支的基础,另一种是你不传递的东西。如果您确实在case中指定了一个表达式语句然后评估所有其他条件并与===进行比较.在这种情况下org评估为false和org===false显然不是真的。所有其他情况也是如此,它们要么是真的,要么是假的。
我有以下内容:text.gsub(/(lower)(upper)/,'\1\2')我可以将\2替换为大写吗?类似于:sed-e's/\(abc\)/\U\1/'这在Ruby中可行吗? 最佳答案 查看gsub文档:str.gsub(模式){|匹配|block}→new_str在block形式中,当前匹配字符串作为参数传入,$1、$2、$`、$&、$'等变量将被适当设置。block返回的值将替换为每次调用的匹配项。"alowerupperb".gsub(/(lower)(upper)/){|s|$1+""+$2.upcase}
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭9年前。我正在创建一个Sinatra应用程序,它采用上传的CSV文件并将其内容放入哈希中。当我像这样在我的app.rb中引用这个散列时:hash=extract_values(path_to_filename)我不断收到此错误消息:undefinedmethod`bytesize'forHash:0x007fc5e28f2b90#object_idfile:utils.rblocation:bytesiz
2个数组的数组:a=[[1,2],[22,11],[18,9]]b=[[1,81]]用[0,0]填充第二个的最佳方法是什么,以便它们具有相同的大小? 最佳答案 b.fill(b.size..a.size-1){[0,0]} 关于ruby-使2个数组大小相同,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/29725615/
我收到“ArgumentError:数组大小太大”消息,代码如下:MAX_NUMBER=600_000_000my_array=Array.new(MAX_NUMBER)问题。Array.new函数在Ruby中的最大值是多少? 最佳答案 具有5亿个元素的数组的大小为2GiBytes,这取决于您使用的特定操作系统,通常是一个进程可以处理的最大值。换句话说:您的数组大于您的地址空间。因此,解决方案很明显:要么缩小数组(例如,将其分成block),要么扩大地址空间(在Linux中,您可以修补内核以获得3、3.5甚至4GiByte地址空间,
Model.exists?("lower(email)=?",params[:email].downcase)返回错误:ArgumentError(参数数量错误(2代表0..1)):是否可以使用不区分大小写的匹配来执行exists?? 最佳答案 您需要做的就是:Model.exists?(["lower(email)=?",params[:email].downcase])它正在寻找一个参数,但您提供了两个。使用数组形式和查找式条件应该可以满足您的需求。 关于ruby-on-rails-
给定一个数组['a','b','c','d','e','f'],我如何获得包含两个的所有子集的列表、三、四元素?我是Ruby的新手(从C#迁移过来),不确定“Ruby之道”是什么。 最佳答案 查看Array#combination然后是这样的:2.upto(4){|n|array.combination(n)} 关于ruby-使用Ruby在数组中查找大小为N的所有子集,我们在StackOverflow上找到一个类似的问题: https://stackoverf