gpt4 book ai didi

android - 布局在图形布局和实际设备上出现不同

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:03:35 24 4
gpt4 key购买 nike

我有以下 XML 布局代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10" >

<VideoView
android:id="@+id/videoView_player"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="8.5" />

<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1.5"
android:gravity="center"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView_indicator"
android:layout_width="50dp"
android:layout_height="50dp" />

<ImageButton
android:id="@+id/imageButton_play"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_media_pause" />
</LinearLayout>

</LinearLayout>

它出现在我的图形布局中,如下所示。 enter image description here

但是在我的设备上它看起来像下面这样。 enter image description here

在实际设备中,右侧占用的面积大于分配的重量。我尝试了很多东西但没有成功。我的代码有什么问题???

最佳答案

它可能正在根据视频的纵横比进行 self 调整。将 VideoView 放在另一个具有正确权重的 View 中。

试试这段代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="10" >

<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="8.5">

<VideoView
android:id="@+id/videoView_player"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</FrameLayout>

...

关于android - 布局在图形布局和实际设备上出现不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16271859/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com