Android – the layout differs between the graphical layout and the actual device
•
Android
I have the following XML layout code:
<?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 appears in my graphic layout as shown below
But on my device, it seems as follows
The area occupied on the right side of the actual equipment is greater than the specified weight. I tried a lot but failed. What's the problem with my code???
resolvent:
It may be adjusted according to the aspect ratio of the video. Place the videoview in another view with the correct weight
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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码