有没有办法让视频视图不是默认视图



这个问题可能令人困惑,所以让我概述一下。

当我通过点击按钮加载活动时,该活动首先加载在活动的底部,而不是应该加载的顶部。现在,仅针对我设计中的上下文,视频视图是"视频"部分的一部分,该部分是在活动底部加载的最后一个元素。

我试过做一些事情,比如删除视频视图和设置不同的锚点视图。但到目前为止,我唯一能解决这个问题的方法就是去掉视频视图。

我将附上我看到的没有视频视图和视频视图的问题的视频。

如果有人能帮忙,我将不胜感激。

这是一个没有视频视图的布局链接(将其作为工作示例(:

https://drive.google.com/file/d/1uhswtYUrJYnC22mlsdJzmRJqNua9mUrw/view?usp=sharing

以下是带有视频视图的布局链接:https://drive.google.com/file/d/1unHp-7GULO_TEdg6KHNjAoIOW6X-N2Rs/view?usp=sharing

我还将为添加的上下文添加视频视图部分的XML和java:

XML文件:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp">
<TextView
android:id="@+id/videos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="0dp"
android:text="Videos"
android:textAllCaps="true"
android:textColor="#000"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_margin="8dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center" />
</FrameLayout>

</androidx.cardview.widget.CardView>
</RelativeLayout>
</RelativeLayout>

Java代码:

VideoView videoView;
private Context mContext;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.company_solo_page);
businessesList = new ArrayList<>();
business_name = findViewById(R.id.bus_name);
business_logo = findViewById(R.id.profile_image);
bdesc = findViewById(R.id.bdesc);
website = findViewById(R.id.website);
social = findViewById(R.id.socialmedia);
careers = findViewById(R.id.careers);
contact = findViewById(R.id.contact);
videoView = findViewById(R.id.videoview);
videoView.setVideoPath(getIntent().getStringExtra("videos"));
videoView.start();
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
mediaController.setAnchorView(videoView);

使用一个可运行的处理程序,可以延迟调用的videoView.start((函数的执行

最新更新