创建半透明背景图像到布局

问题描述 投票:0回答:1

例如,请参见图片

我想要实现一个登录屏幕,我希望用户只需登录Google加登录。我一直在寻找可供选择的设计,但无法理解。但后来我遇到了类似的东西。我试图实现它。

这是我试过的。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.bt4u.shopcite.login">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha=".5"
        android:background="@drawable/ny"/>

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="@dimen/_100sdp"
        android:layout_height="@dimen/_100sdp"
        android:layout_centerHorizontal="true"
        app:srcCompat="@drawable/applogo" />

    <com.google.android.gms.common.SignInButton
        android:id="@+id/Sign_in_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:alpha="1" />
</RelativeLayout>

你可以看到我试图使用alpha但它没有给我相同的结果。我想要一个克隆类型的图像显示。

android xml user-interface
1个回答
0
投票
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bt4u.shopcite.login">

<ImageView
    android:id="@+id/yourbackgroundImageIDD"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:srcCompat="@drawable/yourbackgroundImage" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66000000"">
</LinearLayout>
<ImageView
    android:id="@+id/imageView3"
    android:layout_centerHorizontal="true"
    android:layout_width="@dimen/_100sdp"
    android:layout_height="@dimen/_100sdp"
    app:srcCompat="@drawable/applogo" />
<com.google.android.gms.common.SignInButton
android:id="@+id/Sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>

您可以尝试以上布局。设置背景图像,然后用背景颜色设置LinearLayout,并在十六进制代码中设置alpha,如“#66000000”,其中66alpha,为黑色。

你可以参考这个alpha的其他值:Hex transparency in colors

© www.soinside.com 2019 - 2024. All rights reserved.