我有什么:我有一个显示视频的视频视图
我想要实现的目标:我正在尝试通过修改容器相对布局的高度来调整视频大小。
正在发生的事情:视频已调整大小,但如下所示
----------------------------------------------------------
| | |
| | |
| | |
| | |
| | |
| | |
|----------------- |
| |
| |
| |
----------------------------------------------------------
我想要实现的目标:
----------------------------------------------------------
| | |
| | |
| | |
| | |
| | |
| | |
| |----------------|
| |
| |
| |
----------------------------------------------------------
较小的正方形是视频
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"
android:id="@+id/rootParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
app:srcCompat="@drawable/third_shape"
android:id="@+id/addForLShape" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right">
<RelativeLayout
android:orientation="vertical"
android:id="@+id/activity_main"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
代码:
activity_main.getLayoutParams().width = calcWidth;
activity_main.getLayoutParams().height = calcHeight;
activity_main.requestLayout();
答案 0 :(得分:0)
尝试在调整大小的布局的父布局上调用requestLayout();