百变锁屏

1、在主题包锁屏文件总控脚本(unlock/theme.xml)中,加入如下代码:

<item maxHeight="2160"/>

效果如下:
<?xml version="1.0" encoding="utf-8"?>
<HWTheme>
   <item style="amazing"/>
   <item layout="layout"/>
   <item slideinAmaze="true"/>
   <item maxHeight="2160"/>
</HWTheme>
3、在主题锁屏文件夹 unlock/layout-hdpi 中,打开 layout_.xml ,其中 y值、h值 坐标可以根据设计师的强迫症程度进行修改;
此处引入新的系统变量 system.screen_height,用于在百变锁屏中直接获取当前的屏幕高度(system.screen_height=当前屏幕实际高度,即1920或2160),解决百变锁屏的自适应18:9的屏幕问题。
推荐的写法如下
  • 注意以1920为基点,确认布局在1920*1080屏幕中的坐标位置与高度,算出1920与坐标位置的差值作为布局中的系数
  • 对于需要全屏的壁纸或挂件,如定时换壁纸的主题、有音乐背景的主题等,解决办法如下:
      以定时换壁纸的主题为例:
      由于原本的unlock中壁纸尺寸为1080x1920,且系统无法自动缩放,会引起异常,故此类锁屏按照以下方法解决:
      需要全屏显示的unlock图片,准备1080x1920 、1080x2160各一张,其中1080x2160的图片命名在1080x1920的图片命名前加入前缀“2160_”,布局中图片高度h="system.screen_height" ,资源src加入“‘system.screen_height’+”前缀
      以前的写法:
<StartPoint x="0" y="0" w="1080" h="1920"/>
<image x="0" y="0" w="1080" h="1920" src="´huan´+system.time.min1+´.jpg´"/>
      现在的写法:
<StartPoint x="0" y="0" w="1080" h=" system.screen_height "/>
<image x="0" y="0" w="1080" h="system.screen_height" src="´system.screen_height´+´huan´+system.time.min1+´.jpg´"/>

 

 

   
最后,提供几个案例参考
 
百变锁屏---老司机带你适配全面屏
 

posted @ 2020-05-22 17:24  一牛头  阅读(297)  评论(0)    收藏  举报