【发布时间】:2018-09-03 21:16:34
【问题描述】:
我使用 YouTubePlayerFragment 作为上面带有 textview 的片段。不知何故,标题被隐藏了,渲染时只有空白。很明显,TextView 存在那里,但没有显示。当我将可见性设置为不可见时,我得到了同样的效果。
现在:
目标:
查看此视图的 XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_title"
style="@style/movieTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/details_title_left"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Trailers"
android:layout_marginLeft="@dimen/details_title_left" />
<fragment
android:id="@+id/youtubeFragment"
android:name="com.google.android.youtube.player.YouTubePlayerFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
</android.support.constraint.ConstraintLayout>
在主要活动中,我将此布局与包含标签一起使用,并在单击按钮时更改其可见性。
【问题讨论】:
-
您在
TextView上设置了android:visibility="invisible",所以我希望它是不可见的... -
这只是一个例子。没有它就不会出现。截图后忘记删除了。问题已编辑。
-
您确定@style/movieTitle 中的文本颜色和背景颜色不同吗?
-
是的。在另一个包含的布局中使用了相同的样式,该布局显示标题为“关于”的概述。
-
如何设置
TextView中显示的文字?确定不为空?
标签: android android-fragments youtube youtube-data-api android-constraintlayout