如何将相对布局背景设置为透明

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

我有一个RelativeLayoutImageButton。我需要在跑步时只显示ImageButton。现在它显示按钮,包括RelativeLayout

<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"
    android:background="@android:color/transparent"
    tools:context="com.austurn.raksha.raksha.MainActivity">


<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0"
        android:background="@android:color/holo_blue_bright" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent">


        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter"
            app:srcCompat="@drawable/pushme" />
    </RelativeLayout>
</FrameLayout>


</RelativeLayout>

我的屏幕视图

enter image description here

所需的屏幕

Required screen-click here

android android-layout
1个回答
0
投票

如果要在ImageView上显示按钮,请尝试以下操作:

<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"
    android:background="@android:color/transparent"
    tools:context="com.austurn.raksha.raksha.MainActivity">


    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/holo_blue_bright" />


        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@android:color/transparent"
            android:scaleType="fitCenter"
            app:srcCompat="@drawable/pushme" />

</RelativeLayout>
© www.soinside.com 2019 - 2024. All rights reserved.