如何解决从片段中删除白色背景
我有一个包含一个文本视图的片段,我只希望显示文本。
默认情况下,片段会像这样放置白色背景。
我只想将背景设置为透明。
这是我用于该片段的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会使整个片段消失。
任何建议都很好,谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。