这个问题可能令人困惑,所以让我概述一下。
当我通过单击按钮加载活动时,此活动首先在活动的底部加载,而不是在其预期的顶部加载。现在只是为了我的设计中的上下文,视频视图是“视频”部分的一部分,它是在活动底部加载的最后一个元素。
我尝试过一些事情,例如删除视频视图和设置不同的锚视图。但最终,到目前为止,我设法解决此问题的唯一方法是摆脱视频视图。
我会附上我在没有视频视图和视频视图的情况下看到的问题的视频。
如果有人能提供帮助,我将不胜感激。
这是没有视频视图的布局的链接(将此作为工作示例):
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);
答案 0 :(得分:0)
使用 handler 和 runnable 可以延迟 videoView.start() 函数调用的执行