Отключить автоматическое расширение текста редактирования при наборе текста - PullRequest
0 голосов
/ 04 декабря 2018

Моя активность: 1 youtubePlayerView, 1 текст редактирования ниже.Мое видео на YouTube останавливается случайно, когда я набираю более 4 строк в тексте редактирования.Я думаю, причина в том, что другой макет поверх макета 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" />

Ответы [ 2 ]

0 голосов
/ 04 декабря 2018

спасибо за помощь, ребята, я решил эту проблему, используя другой способ.

добавьте приведенные ниже коды в onCreated (), чтобы изменить размер всего представления при появлении клавиатуры, чтобы раскладка клавиатуры былане поверх макета youtubePlayerView, тогда видео не будет остановлено.

this.getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
0 голосов
/ 04 декабря 2018

, чтобы решить эту проблему, добавьте этот код в ваш EditText

android:layout_width="0dp"
android:layout_weight="1"
...