2017-11-07 10 views

답변

3

이 ::

<ImageView 
android:id="@+id/imageview" 
android:layout_width="wrap_parent" 
android:layout_height="wrap_parent" 
android:foreground="@drawable/image_overlay" 
android:src="@drawable/your_image" /> 

image_overlay.xml처럼 이미지 뷰를 설정

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient 
     android:startColor="#401C87C0" 
     android:centerColor="#401C87C0" 
     android:endColor="#401C87C0" 
     /> 
</shape> 

나는 색상 코드 = # 1C87C0를 사용하여 최종 색상 코드가 될 수 있도록 25 % 불투명도로 설정 # 401C87C0처럼 당신은 : 귀하의 요구 사항에 따라 색상 정의의 첫 번째 두 문자를 변경 색상의 투명도를 변경할 수 있습니다

100% — FF 
99% — FC 
98% — FA 
97% — F7 
96% — F5 
95% — F2 
94% — F0 
93% — ED 
92% — EB 
91% — E8 

90% — E6 
89% — E3 
88% — E0 
87% — DE 
86% — DB 
85% — D9 
84% — D6 
83% — D4 
82% — D1 
81% — CF 

80% — CC 
79% — C9 
78% — C7 
77% — C4 
76% — C2 
75% — BF 
74% — BD 
73% — BA 
72% — B8 
71% — B5 

70% — B3 
69% — B0 
68% — AD 
67% — AB 
66% — A8 
65% — A6 
64% — A3 
63% — A1 
62% — 9E 
61% — 9C 

60% — 99 
59% — 96 
58% — 94 
57% — 91 
56% — 8F 
55% — 8C 
54% — 8A 
53% — 87 
52% — 85 
51% — 82 

50% — 80 
49% — 7D 
48% — 7A 
47% — 78 
46% — 75 
45% — 73 
44% — 70 
43% — 6E 
42% — 6B 
41% — 69 

40% — 66 
39% — 63 
38% — 61 
37% — 5E 
36% — 5C 
35% — 59 
34% — 57 
33% — 54 
32% — 52 
31% — 4F 

30% — 4D 
29% — 4A 
28% — 47 
27% — 45 
26% — 42 
25% — 40 
24% — 3D 
23% — 3B 
22% — 38 
21% — 36 

20% — 33 
19% — 30 
18% — 2E 
17% — 2B 
16% — 29 
15% — 26 
14% — 24 
13% — 21 
12% — 1F 
11% — 1C 

10% — 1A 
9% — 17 
8% — 14 
7% — 12 
6% — 0F 
5% — 0D 
4% — 0A 
3% — 08 
2% — 05 
1% — 03 
0% — 00 
+0

완전 투명이 더 많은 설명과 나를 위해 작동합니다. –

+1

다행이 도움이됩니다. – Maroof

1

enter image description here

변화는 당신은 FrameLayout이 내 이미지 뷰를 둘러싸고 있습니다.

<FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:foreground="@color/semi_transparent_color"> 

     <ImageView 
      android:layout_width="200dp" 
      android:layout_height="200dp" 
      android:src="@drawable/your_image" /> 
    </FrameLayout> 

여기에 반투명 색상을 사용할 수 있습니다. # 22000000과 같은 값일 수 있습니다.

0

는 반투명 색상에 FrameLayout이의 마지막 자식으로 간단한보기를 추가하고 배경을 설정합니다. 오버레이보기의 가시성을 적절하게 설정하십시오 (View.VISIBLE 또는 View.GONE).

0

android:alpha="0.6"과 같은 알파를 ImageView에 추가하고 FrameLayout에 기본 색상을 blue=#2196F3과 같이 지정하면됩니다.

<FrameLayout 
    android:background="#2196F3" 
    android:layout_width="..." 
    android:layout_height="..."> 

    <ImageView 
     android:alpha="0.6" 
     android:layout_width="..." 
     android:layout_height="..." 
     android:src="@drawable/image" /> 

</FrameLayout> 

알파 값 1.0에서 0.0까지의 범위이다. 예를 들어 :

  • 1.0인가
  • 0.5 투명하지 반투명
  • 0.0