【发布时间】:2016-11-01 03:20:40
【问题描述】:
我在 onCreate 方法中将以下内容设置为可见。
findViewById(R.id.noDesignsCallToAction).setVisibility(View.VISIBLE);
在 XML 中,视图设置为可见性消失。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="vertical"
android:layout_below="@id/toolbar"
android:id="@+id/linearLayout">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/go_ahead_create_something_n_it_s_really_easy_n_just_click_here_to_get_started"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/noDesignsCallToAction"
android:padding="10dp"
android:textSize="14sp"
android:typeface="sans"
android:visibility="gone"
android:onClick="LaunchCustomizer"
android:gravity="center_vertical|center_horizontal" />
</LinearLayout>
为什么 textview 在我的应用中不可见?
【问题讨论】:
-
你能发布整个布局 XML 吗?
-
如果你给它充气然后设置它的可见性,它会起作用吗?像 TextView tv = (TextView) findView...; tv.setVisibility(View.VISIBLE); 也许你的字符串 res 是空的?
-
真正想要做什么?
-
从未发现 setVisibility 有任何问题。发布您的整个 XML 和相关的 java 代码。可能由于某种原因,视图位于窗口之外,或者您在错误的时间调用了 setVisibility ......类似的事情
标签: java android textview imageview visibility