Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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
Java 从片段中删除白色背景_Java_Android_Android Fragments_Android Linearlayout_Transparency - Fatal编程技术网

Java 从片段中删除白色背景

Java 从片段中删除白色背景,java,android,android-fragments,android-linearlayout,transparency,Java,Android,Android Fragments,Android Linearlayout,Transparency,我有一个片段,其中包含一个文本视图,我只想显示文本 默认情况下,片段放置如下白色背景 我只希望背景设置为透明 这是我对该片段的xml <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background=&quo

我有一个片段,其中包含一个文本视图,我只想显示文本

默认情况下,片段放置如下白色背景

我只希望背景设置为透明

这是我对该片段的xml

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    >

    <TextView
        android:id="@+id/cityNameTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:textSize="25dp"
        android:fontFamily="@font/baloo_thambi"

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"

        />

</androidx.constraintlayout.widget.ConstraintLayout>

我在堆栈溢出上找到了3个“明显的解决方案”。如下文所述,但这并没有解决任何问题

  • 到目前为止,我已经尝试将背景设置为透明,如上图所示

  • 将alpha值设置为0.0,使其完全消失

  • 将可见性设置为“消失”

  • 将背景设置为透明不起任何作用,而2和3会使整个片段消失

    任何建议都很好,谢谢