微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我有以下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>

它出现在我的图形布局中,如下所示.

但在我的设备上它似乎如下.

在实际设备右侧占用的面积大于指定的重量.我尝试了很多但没有成功.我的代码有什么问题???

解决方法:

它可能会根据视频的宽高比进行调整.
将VideoView放在具有正确重量的另一个视图中.

试试这段代码

<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>

...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。