-7
我想設計一個完全像下圖所示的佈局。我怎麼可以在android工作室透明背景?
當我把我的線性佈局alpha透明化時,它裏面的所有圖標也變得透明並且完全正常。但我想要一種方式來讓透明背景不是所有的項目!
我希望有一個透明的佈局是這樣的:
但我的佈局,這樣表示:
這裏是我的代碼:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:alpha="0.5"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333"
android:padding="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="1dip"
android:layout_height="fill_parent"
android:layout_weight="0.333">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/consert"
android:layout_gravity="center_horizontal"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
使背景透明的佈局,然後在tranparent部分設置您的圖標。而你的結果會讓你開心 –
我認爲這是我所做的!你能告訴我如何在我的代碼中修復它嗎? tnx – Saeid
在頂部的LinearLayout上,只需給它一個透明的背景顏色,比如說做一個#FF000000,這樣可以防止佈局小部件受到alpha屬性的影響。 –