android - 调整调整大小导致进度条向右移动
问题描述
我在RelativeLayout 中有一个进度条。一切正常,直到我显示软键盘并且进度条向右移动。
<RelativeLayout
android:id="@+id/fragment_video_video_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintHeight_percent=".33"
app:layout_constraintWidth_default="percent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<VideoView
android:id="@+id/fragment_video_video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/video_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
如何防止进度条向右移动?
编辑1:_______________整个布局_______________________________
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/blackBackground">
<RelativeLayout
android:id="@+id/fragment_video_video_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintHeight_percent=".33"
app:layout_constraintWidth_default="percent"
app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<VideoView
android:id="@+id/fragment_video_video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/video_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
<TextView
android:id="@+id/fragment_video_textview_chat"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:text="Chat"
android:textColor="@color/colorBlack"
app:layout_constraintTop_toBottomOf="@+id/fragment_video_video_layout"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:background="@color/whiteText"
android:paddingLeft="12dp"/>
<RelativeLayout
android:id="@+id/fragment_video_sendmessage_layout"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_alignParentBottom="true"
android:background="@color/whiteText"
app:layout_constraintBottom_toBottomOf="parent">
<View
android:id="@+id/fragment_video_video_divider1"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/dividerColor"/>
<EditText
android:id="@+id/fragment_video_sendmessage_edittext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Say something in chat"
android:textSize="14sp"
android:paddingLeft="12dp"
android:background="@null"
android:layout_toLeftOf="@+id/fragment_video_sendmessage_button"
android:inputType="text"
android:maxLines="1"
android:layout_below="@+id/fragment_video_video_divider1"/>
<Button
android:id="@+id/fragment_video_sendmessage_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:text="Send"
android:background="@null"
android:textAllCaps="false"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="10dp"
android:layout_below="@+id/fragment_video_video_divider1"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/fragment_video_recycler"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/fragment_video_textview_chat"
app:layout_constraintBottom_toTopOf="@id/fragment_video_sendmessage_layout"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="@color/whiteText">
</android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>
编辑 2:____________________________________________
尝试将进度条更改为
android:layout_width="match_parent"
这修复了移动进度条,但它会导致视频视图移动
解决方案
它在我添加android:layout_centerInParent="true"
VideoView 时起作用。
<VideoView
android:id="@+id/fragment_video_video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
推荐阅读
- angular - 如何在Angular2 +中制作自定义指令以在数字之间给出?
- python - 如何将 jinja 值设置为 html 标签
- node.js - npm 脚本因 sh: 1 失败:
: 在 docker 容器中找不到 - android - 一台设备中的电话身份验证 Firebase 错误
- javascript - 在 ES6 中返回对象内部方法的数据
- javascript - res.redirect("/"); 此代码不起作用,并且在 chrome 检查中显示错误 302
- python - 如何反转未知维度的numpy数组?
- mysql - 如何解决OctoberCMS 数据库丢失?
- vue.js - 在 vuex 中存储敏感信息
- java - 使用 Java 流从字符串数字列表中查找最大数字