AndroidStudio 1.5
我想创建一个透明背景的图标和文字上。但我不想让图标或文字透明。在dialer_pad.xml
我试图设置阿尔法,但每次我这样做的图标和文字也将变得透明。
正如你所看到的图标和文字是透明的。我只是想让背景透明。
我已经尝试了很多事情来设置阿尔法只得到周围的背景是透明的,而留下的文字和图标独。我认为制作一个图层列表可能会起作用。
这可能吗?
任何建议非常感谢,
contacts.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:background="@drawable/inner_border">
<ImageView
android:id="@+id/ivContacts"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:padding="16dp"
android:src="@drawable/ic_people_white_48dp"
android:layout_gravity="center"/>
<TextView
android:id="@+id/tvHold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contacts"
android:textSize="12sp"
android:textColor="@android:color/white"
android:fontFamily="sans-serif-condensed"
android:layout_gravity="bottom|center"/>
</FrameLayout>
call.xml
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:background="@drawable/right_border">
<ImageView
android:id="@+id/ivSwitch"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:padding="16dp"
android:src="@drawable/ic_phone_white_48dp" />
<TextView
android:id="@+id/tvHold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Make Call"
android:textSize="12sp"
android:fontFamily="sans-serif-condensed"
android:textColor="@android:color/white"
android:layout_gravity="bottom|center"/>
</FrameLayout>
dialer_pad.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/outer_border"
android:alpha="0.5">
<TableRow>
<include
layout="@layout/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<include
layout="@layout/contacts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ssd.MainActivity"
android:gravity="center_vertical|center_horizontal"
android:background="@drawable/background">
<include layout="@layout/dialer_pad"/>
</RelativeLayout>
的getBackground()。setAlpha()犯规帮助你吗? – Nanoc
带有alpha的FrameLayout容器0-1 里面的文字,图标 – pvllnspk
@pvllnspk在FrameLayout上设置alpha值将为孩子添加透明度,以便图片和文字透明。我只想要文字和图标所在的背景是透明的。不加任何透明地留下图标和文字。 – ant2009