直播系统平台搭建,状态栏透明和代码设置渐变色

直播系统平台搭建,状态栏透明和代码设置渐变色实现的相关代码

1.状态栏透明和去掉标题栏

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
状态栏透明:
WindowManager.getInstance().getTopWindow().get().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
去掉状态栏:
getWindow().addFlags(WindowManager.LayoutConfig.MARK_FULL_SCREEN);
去掉标题栏
  "abilities" : [
"metaData" :{
           "customizeData" :[
             {
               "name" "hwc-theme" ,
               "value" "androidhwext:style/Theme.Emui.Light.NoTitleBar" ,
               "extra" ""
             }
           ]
         }
]

2.代码设置渐变色shape


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
由于看到不能在shape直接设置渐变,所以找到一个公共方法去设置:
     /**
      * 渐变色背景
      */
     public  static  ShapeElement getButtonShape(AbilityContext context,  float  radius,  int  resStartId,  int  resEndId) {
         ShapeElement shapeElement =  new  ShapeElement();
         shapeElement.setCornerRadius(radius);
         shapeElement.setShape(ShapeElement.RECTANGLE);
         //color关键值
         RgbColor[] rgbColors =  new  RgbColor[]{
                 RgbColor.fromArgbInt(context.getColor(resStartId)),
                 RgbColor.fromArgbInt(context.getColor(resEndId))};
         shapeElement.setRgbColors(rgbColors);
         //线性变化:对应type="linear"
         shapeElement.setShaderType(ShapeElement.LINEAR_GRADIENT_SHADER_TYPE);
         //变化方向,从左到右:对应angle="0"
         shapeElement.setGradientOrientation(ShapeElement.Orientation.LEFT_TO_RIGHT);
         return  shapeElement;
     }
     /**
      * 通过id获取View
      */
     public  static  extends  Component> T findById(AbilitySlice context,  int  id) {
         return  (T) context.findComponentById(id);
     }


以上就是直播系统平台搭建,状态栏透明和代码设置渐变色实现的相关代码, 更多内容欢迎关注之后的文章


请使用浏览器的分享功能分享到微信等