Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我如何保持活动的一部分固定不变_Java_Android_Xml - Fatal编程技术网

Java 我如何保持活动的一部分固定不变

Java 我如何保持活动的一部分固定不变,java,android,xml,Java,Android,Xml,我正在制作一个应用程序,允许用户流式播放视频,然后在视频下方进行评论/提问。当键盘打开时,视频播放器会滚动,为键盘在屏幕上腾出空间 活动的布局: <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" an

我正在制作一个应用程序,允许用户流式播放视频,然后在视频下方进行评论/提问。当键盘打开时,视频播放器会滚动,为键盘在屏幕上腾出空间

活动的布局:

<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:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:weightSum="2"
tools:context=".LiveVideoBroadcasterActivity">

//player portion starts here

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:isScrollContainer="false"
    android:layout_weight="0.7">

    <android.opengl.GLSurfaceView
        android:id="@+id/cameraPreview_surfaceView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:orientation="horizontal"
        android:padding="2dp"
        android:visibility="visible"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageButton
            android:id="@+id/settings_button"
            style="?borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|bottom"
            android:adjustViewBounds="true"
            android:onClick="showSetResolutionDialog"
            android:src="@drawable/ic_settings_white_24dp"
            android:tint="@color/colorAccent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageButton
            android:id="@+id/changeCameraButton"
            style="?attr/borderlessButtonStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:onClick="changeCamera"
            android:src="@drawable/ic_switch_camera_white_24dp"
            android:tint="@color/colorAccent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toEndOf="@+id/settings_button"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/stream_live_status"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end|top"
            android:layout_margin="8dp"
            android:layout_marginEnd="4dp"
            android:background="@drawable/rounded_live"
            android:padding="5dp"
            android:text="@string/live_indicator"
            android:visibility="gone"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

 //player portion ends here

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1.3"
    android:orientation="vertical"
    android:visibility="visible">

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="@+id/linearLayout3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.core.widget.NestedScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="50dp"
            android:paddingTop="40dp">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/show_chat"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </androidx.core.widget.NestedScrollView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <EditText
            android:id="@+id/stream_name_edit_text"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:hint="@string/stream_name"
            android:textColor="@color/colorAccent"
            android:textColorHint="@color/colorSelect" />

        <Button
            android:id="@+id/toggle_broadcasting"
            style="@style/TextAppearance.AppCompat.Widget.Button"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:backgroundTint="@color/colorPrimaryDark"
            android:onClick="toggleBroadcasting"
            android:text="@string/start"
            android:textColor="@color/colorAccent" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@drawable/chatbox"
        android:weightSum="3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <EditText
            android:id="@+id/textmassge"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:layout_weight="2.5"
            android:hint="Enter Message"
            android:textColor="@color/colorPrimary"
            android:textColorHint="@color/colorPrimary"
            android:textSize="20sp"
            tools:ignore="Autofill,HardcodedText" />

        <androidx.appcompat.widget.AppCompatImageButton
            android:id="@+id/send_button"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:background="@android:color/transparent"
            android:src="@drawable/ic_arrow_back_black_24dp"
            android:tint="@color/colorAccent" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

//玩家部分从这里开始
//玩家部分到此结束


我试图将整个布局保持在一个约束布局和一个给定的静态高度和宽度中,但由于我需要应用程序具有足够的响应能力,以便能够跨多个设备工作,因此我选择了使用linearlayout和weightsum的这种方法。

您是否尝试过添加
android:WindowsofInputMode=“adjustNothing”
添加到清单中的活动声明?@AgiMaulana是的,我添加了,但不起作用。您是否尝试将
android:windowSoftInputMode=“adjustNothing”
添加到清单中的活动声明?@AgiMaulana是的,我添加了,但不起作用