【发布时间】:2018-12-04 07:49:38
【问题描述】:
我的活动有:1 个 youtubePlayerView,下面有 1 个编辑文本。 当我在编辑文本中输入超过 4 行时,我的 youtube 视频意外停止。 我认为原因是 youtubePlayer 布局之上的其他布局,使 youtube 视频停止。
这是 LogCat: W/YouTubeAndroidPlayerAPI:YouTube 视频播放因播放器顶部未经授权的覆盖而停止。 YouTubePlayerView 被 android.view.View 遮挡 任何人都有编辑扩展问题的解决方案。
这是我在手机上录制的链接 youtube 视频,用于演示此错误: https://youtu.be/zE8vzmaT0-Q
这是我用于该活动的 xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:weightSum="13"
tools:context=".StudyActivity">
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/youtubeView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"></com.google.android.youtube.player.YouTubePlayerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"
android:background="#1d75a1"
android:elevation="18dp"
android:orientation="horizontal"
android:padding="1.5dp"
android:weightSum="16">
<ImageButton
android:id="@+id/btPreviousTrack"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="2.5"
android:background="#bdf6f9"
android:src="@drawable/previous_track" />
<Spinner
android:id="@+id/spinnerSelectTrack"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.5"></Spinner>
<ImageButton
android:id="@+id/btNextTrack"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.5"
android:background="#bdf6f9"
android:src="@drawable/next_track" />
<ImageButton
android:id="@+id/btCheck"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginLeft="5dp"
android:layout_weight="8.5"
android:background="#bdf6f9"
android:src="@drawable/check_green_mark" />
</LinearLayout>
<EditText
android:id="@+id/etAnswer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.5"
android:background="#5abce6"
android:elevation="15dp"
android:ems="10"
android:gravity="start"
android:hint="type answer here"
android:inputType="textMultiLine"
android:textSize="24sp"
android:lines="5"
android:maxLines="5"/>
<TextView
android:id="@+id/tvResult"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:background="#8edaf1"
android:elevation="1dp"
android:textSize="24sp" />
【问题讨论】:
-
尝试将 maxHeight 赋予您的 editText,这将避免在给定高度之后扩展您的 EditText。
-
谢谢,但是edittext还是会展开,没什么不同
标签: android android-youtube-api