Sae*_*eid -8 layout android alpha transparent
我想设计一个与下图完全相同的布局。
当我将线性布局 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>
Run Code Online (Sandbox Code Playgroud)
如果你想调整透明改变颜色的alpha,你可以尝试这样,我给的#55000000你可以改变alpha值(55)任何你想要的。如果你想要黑色透明,你可以使用#55FFFFFF
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:background="#55000000"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/ic_launcher"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29249 次 |
| 最近记录: |