问题描述
默认情况下,片段会像这样放置白色背景。
我只想将背景设置为透明。
这是我用于该片段的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 (将#修改为@)