Android 背景透明度设置和设置GridView元素间距
一、设置背景透明度
Android开发过程中经常使用背景,有时候为了使按钮或者是GridView的元素更加明显,需要设置背景透明度。
比如设置10%的背景透明度:android:background="#1A000000"
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1A000000">// 设置背景透明度。
</RelativeLayout>
设置60%透明度
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000">//60%透明度
如果像设置其他透明度可以参考以下
100% — #FF000000
95% — #F2000000
90% — #E6000000
85% — #D9000000
80% — #CC000000
75% — #BF000000
70% — #B3000000
65% — #A6000000
60% — #99000000
55% — #8C000000
50% — #80000000
45% — #73000000
40% — #66000000
35% — #59000000
30% — #4D000000
25% — #40000000
20% — #33000000
15% — #26000000
10% — #1A000000
5% — #0D000000
0% — #00000000
二、设置GridView 元素间距
android:verticalSpacing=“15dp”//设置每行之间的间距
android:horizontalSpacing=“15dp”//设置每列之间的间距
比如 android:verticalSpacing=“15dp” 设置行距15dp