Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使线性布局背景透明_Android_Android Layout - Fatal编程技术网

Android 使线性布局背景透明

Android 使线性布局背景透明,android,android-layout,Android,Android Layout,如何使线性布局的背景透明 我想使共享按钮周围的区域透明。我尝试过各种解决方案,比如 android:background="@android:color/transparent" 及 还有许多其他的解决方案,但似乎都不起作用。 如何使该区域在图像和其他元素上透明? 我也尝试过框架布局,但也不起作用 以下是我的XML代码: <?xml version="1.0" encoding="utf-8"?> <android

如何使线性布局的背景透明

我想使共享按钮周围的区域透明。我尝试过各种解决方案,比如

android:background="@android:color/transparent"

还有许多其他的解决方案,但似乎都不起作用。 如何使该区域在图像和其他元素上透明? 我也尝试过框架布局,但也不起作用

以下是我的XML代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:theme="@style/Theme.MaterialComponents"
    tools:context=".ReadMoreActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:paddingBottom="100dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/readMoreImage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="fitCenter" />

                <TextView
                    android:id="@+id/readMoreTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Card Title"
                    android:textAlignment="center"
                    android:textColor="#000000"
                    android:textSize="30dp" />


                <TextView
                    android:id="@+id/readMoreDesc"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:paddingBottom="20dp"
                    android:text="Card description"
                    android:textAlignment="textStart"
                    android:textColor="#000000" />

            </LinearLayout>

        </ScrollView>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_gravity="center"
            android:layout_marginTop="-100dp"
            android:orientation="horizontal">

            <com.google.android.material.button.MaterialButton
                android:id="@+id/shareButton"
                style="@style/Widget.MaterialComponents.Button.OutlinedButton"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:paddingLeft="50dp"
                android:paddingRight="50dp"
                android:text="Share"
                android:textColor="#ffff"
                android:textSize="25dp"
                app:backgroundTint="#9C27B0"
                app:strokeColor="#9C27B0"
                app:strokeWidth="2dp" />

        </LinearLayout>

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

如果我正确理解你,你可以这样做:



你想让蜘蛛侠成为全屏的背景,而底部的按钮则是透明的线性布局吗?我只想共享按钮周围的所有白色区域都是透明的。我想你已经粘贴了不完整的代码。当我将此代码粘贴到AS并将背景设置为根容器时,线性布局是透明的。我认为很难用代码重新创建图像布局。你想让你的最终布局看起来像吗?@iknow实际上它就像一篇博客文章——首先是图像,然后是标题,然后是描述——所有这些都是从firebase获取的。这一切都在滚动视图,我想在屏幕的最后一个静态按钮,坚持在那个里,我们可以滚动屏幕的其余部分。为此,我使用了布局内部布局,但正如您所看到的,共享按钮周围的白色区域破坏了所有内容,请帮助我。我添加了一个答案,检查它,并让我知道这是否是您想要做的。如果是,请随意接受并投票:谢谢你救了我兄弟/姐姐!!!还有一件事,应用程序:cornerRadius=“xdp”在您的解决方案中不起作用。我如何编辑它。您要将哪个视图应用于
cornerRadius
?我已经编辑了我的答案,现在您可以将radius应用于按钮。您以前无法执行此操作,因为您已设置了
background
属性,而我刚刚复制了您的按钮。谢谢您的解决方案。你知道如何改进这些设计概念吗?欢迎你。很难说,我对材料设计也很陌生,但你可以检查一下。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:theme="@style/Theme.MaterialComponents"
    tools:context=".ReadMoreActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:paddingBottom="100dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/readMoreImage"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="fitCenter" />

                <TextView
                    android:id="@+id/readMoreTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Card Title"
                    android:textAlignment="center"
                    android:textColor="#000000"
                    android:textSize="30dp" />


                <TextView
                    android:id="@+id/readMoreDesc"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:paddingBottom="20dp"
                    android:text="Card description"
                    android:textAlignment="textStart"
                    android:textColor="#000000" />

            </LinearLayout>

        </ScrollView>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="100dp"
            android:layout_gravity="center"
            android:layout_marginTop="-100dp"
            android:orientation="horizontal">

            <com.google.android.material.button.MaterialButton
                android:id="@+id/shareButton"
                style="@style/Widget.MaterialComponents.Button.OutlinedButton"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:paddingLeft="50dp"
                android:paddingRight="50dp"
                android:text="Share"
                android:textColor="#ffff"
                android:textSize="25dp"
                app:backgroundTint="#9C27B0"
                app:strokeColor="#9C27B0"
                app:strokeWidth="2dp" />

        </LinearLayout>

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>