<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:width="3dp"
                android:color="#FF0000" />
            <corners android:radius="8dp" />
        </shape>
    </item>
</layer-list>
QPalette pal = palette(); 
pal.setColor(QPalette::Background, QColor(0x00,0xff,0x00,0x00)); 
setPalette(pal);
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.alpha=1.0f;
dialog.getWindow().setAttributes(lp);
alpha在0.0f到1.0f之间。1.0完全不透明,0.0f完全透明
timer = setInterval(show, 30);本来show是一个自定义函数,
当设为timer = setInterval(show(one,two), 30);时,发现show里面的参数one和two无法被导入,所以需要做以下代码改进和优化
.element {
    background: #D9D9D9;
    opacity: 0.5;
}
journey
    title 设置TextView透明度的步骤概览
    section 创建一个TextView
    section 设置TextView的透明度
    section 显示TextView
int argbColor = Color.argb(alpha, red, green, blue);
<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/image" />
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // 实例化一个UIView
    UIView *view = [[UIView alloc] init];

    /* ----- 基本设置 ----- */
    // 设置尺寸大小及位置 (frame)
    view.frame = CGRectMake(50, 50, 200, 200);
    // 设置背景颜色
    view.backgroundColor = [UIColor redColor];
    // 设置透明度
    view.alpha = 1;   // 透明度0~1

    /* ----- layout设置 ----- */
    //设置view自带CALayer图层的颜色(给CALayer设置的颜色,都要变成CGColor)
//    view.layer.backgroundColor = [UIColor orangeColor].CGColor;
    // 设置边框宽度
    view.layer.borderWidth = 3;
    // 设置边框颜色
    view.layer.borderColor = [UIColor blackColor].CGColor;
    // 设置圆角半径
    view.layer.cornerRadius = 20;

    /* 设置图片 */
//    // 设置图片与设置阴影只能二选一,如果二者都要,只能再添加一个子layer (见下面代码)
//    // 设置Layer渲染的内容
//    view.layer.contents = (id)[UIImage imageNamed:@"23.jpg"].CGImage;
//    // 切除超出父layer的部分
//    view.layer.masksToBounds = YES;

    /* 设置阴影 */
    // 设置layer的阴影
    view.layer.shadowOffset = CGSizeMake(20, 20);
    // 设置layer颜色
    view.layer.shadowColor = [UIColor lightGrayColor].CGColor;
    // 设置layer阴影透明度
    view.layer.shadowOpacity = 0.5;

    /* ----- 添加一层子layer ----- */
    // 实例化子layer
    CALayer *subLayer = [[CALayer alloc]init];
    // 设置frame
    subLayer.frame = view.layer.bounds;
    // 设置圆角
    subLayer.cornerRadius = 100;
    // 设置subLayer的渲染内容
    subLayer.contents = (id)[UIImage imageNamed:@"23.jpg"].CGImage;
    // 切除超出父layer的部分
    subLayer.masksToBounds = YES;
    // 添加到view.layer之上
    [view.layer addSublayer:subLayer];

    // 添加子视图到self.view上
    [self.view addSubview:view];
}


@end
journey
    title Android WindowBackground 设置透明度
    section 了解需求 : 用户需要将 WindowBackground 设置为透明
    section 查找文档 : 查阅 Android 官方文档或其他资料,了解实现方法
    section 编写代码 : 根据文档内容,编写代码实现设置透明度
    section 测试效果 : 运行代码,查看 WindowBackground 是否成功设置为透明
<RelativeLayout xmlns:android="
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/transparent_red">

    <!-- Other UI elements -->

</RelativeLayout>
img
 {
 opacity:0.4;
 filter:alpha(opacity=40); /* For IE8 and earlier */
 }
title: matplotlib 外观和基本配置笔记
 notebook: Python
 tags:matplotlib
 ---
Properties
    {
        _Color("Color",Color)=(1,1,1,1)
        _MainTex ("Texture", 2D) = "white" {}
        _Cutoff("Alpha Cutoff",Range(0,1))=0.5
    }
    SubShader
    {
        Tags{"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCoutout"}
        Pass
        {
            Tags{"LightMode"="ForwardBase"}
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            
            #include "Lighting.cginc"
            #include "UnityCG.cginc"

            fixed4 _Color;
            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed _Cutoff;

            struct v2f
            {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                fixed3 worldNormal :TEXCOORD1;
                fixed3 worldPos :TEXCOORD2;
            };

            v2f vert (appdata_base v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.texcoord ,_MainTex);
                o.worldNormal = UnityObjectToWorldNormal(v.normal);
                o.worldPos = UnityObjectToWorldDir(v.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed3 worldNormal = normalize(i.worldNormal);
                fixed3 worldLightDir = normalize(UnityWorldSpaceLightDir(i.worldPos));

                fixed4 texColor = tex2D(_MainTex,i.uv);
                clip(texColor.a - _Cutoff);
                // if((texColor.a - _Cutoff)<0.0){
                //     discard;
                // }
                fixed3 albedo  = texColor.rgb  * _Color.rgb;
                fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * albedo;
                fixed3 diffuse = _LightColor0.rgb * albedo * saturate(dot(worldNormal,worldLightDir));
                return fixed4(ambient+diffuse,1.0);
            }
            ENDCG
        }
    }
    Fallback "Transparent/Cutoff/VertexLit"
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_with_transparency">

    <!-- 在这里添加其他视图和控件 -->

</RelativeLayout>
android:textColor="#73FFFFFF"

            android:background="#73FFFFFF"
filter:alpha(opacity=80, FinishOpacity=30, style=2);/*支持IE*/
 opacity:0.3;/*支持firefox*/
  • 1
  • 2
  • 3
  • 4
  • 5