图形布局和实际设备上的布局不同
16lz
2021-01-22
I have follwoing XML layout code:
我有以下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>
It is appearing in my Graphical Layout like following.
它出现在我的图形布局中,如下所示。
But on My device it is Appearing like following.
但在我的设备上它看起来像下面。
in actual device right side is taking more area than assigned weight. I have tried many things but no success. What is wrong with my code???
在实际设备右侧占用的面积大于指定的重量。我尝试过很多东西但没有成功。我的代码有什么问题???
1 个解决方案
#1
3
It's probably adjusting itself to the aspect ratio of the video. Put the VideoView
within another view with the correct weight.
它可能会根据视频的宽高比进行调整。将VideoView放在具有正确重量的另一个视图中。
Try this code:
试试这段代码:
<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 软键盘弹出时把原来布局顶上去的解决方法
- javaScript函数中执行C#代码中的函数
- 反编译APK 得到JAVA代码和资源文件源码
- java.io.File vs java.nio.Files这是新代码中的首选?
- 拖动层的javasvript代码 十行代码即可写出兼容版拖动层
- 我无法让这个简单的ajax代码工作
- javascript实现拖动层效果代码(许愿墙)
- 牛客网Java刷题知识点之同步方法和同步代码块的区别(用synchroniz
- 在java自动生成hashCode代码问题? 请大神赐教