簡體   English   中英

如何在LinearLayout中顯示“ visibility =” gone””的TextView

[英]How to show a TextView inside a LinearLayout that is “visibility=”gone“”

我實際上是在Java和AndroidStudio上進行編碼的新手,而且我正在嘗試更新已經存在的應用程序。

我有3個LinearLayout,彼此之間看起來像3個正方形,在最后一個內部,我有一個TewtView。 第一個是主要的,並且始終可見。 當我將我的最后兩個LinearLayout放到visibleibility =“ GONE”中時,我的LinearLayout消失了,我希望我的textView始終可見,即使包含它的LinearLayout不可見。

有可能的?

 <LinearLayout
 style="@style/ColPlayer"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="horizontal" >

 <LinearLayout
 style="@style/SquareBogey"
 android:visibility="gone"
 android:layout_width="70dp"
 android:layout_height="50dp"
 android:orientation="horizontal"
 android:id="@+id/outersquare">

 <LinearLayout
 style="@style/SquareBogey"
 android:visibility="gone"
 android:layout_width="60dp"
 android:layout_height="40dp"
 android:orientation="horizontal"
 android:id="@+id/innersquare">

 <TextView
 android:id="@+id/PlayerCJ01"
 style="@style/ColCJPlayer"
 android:layout_height="wrap_content"
 android:ems="1" />
 </LinearLayout>
 </LinearLayout>
 </LinearLayout>

請問我是否需要更多信息。 謝謝

將父級布局的可見性設置為GONE或INVISIBLE時,其所有子級也將變為GONE或INVISIBLE。

如果要顯示TextView但不顯示其父級LinearLayout ,則可以將TextViewLinearLayout移出,也可以刪除LinearLayout的樣式,使其看起來像消失了,但顯然仍然存在。

LinearLayout的可見性設置為GONE,將其子TextView的可見性設置為VISIBLE無效,因此不是一種選擇。

除了將LinearLayouts的可見性設置為GONE以外,您還可以通過更改其樣式來將其背景/邊框設置為透明。

如果適合您的需要,則取決於您的用例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM