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

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

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

 

状态栏透明:
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

 

 

由于看到不能在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 <T extends Component> T findById(AbilitySlice context, int id) {
        return (T) context.findComponentById(id);
    }

 

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

 

posted @ 2021-10-29 14:53  云豹科技-苏凌霄  阅读(113)  评论(0编辑  收藏  举报