Android 项目,在一个activity内,有一个textureview 一个imageview,现在想设置横屏显示这两个控件,控件的大小各占手机屏幕的一半,两个控件无缝拼接在一起,有知道如何实现的大神吗,救救急!
厄,在androidmainfest里设置activity的属性screenOrigiton为 landscape横屏
android:screenOrientation="landscape">
然后再布局xml中加入LinearLayout
<?xml version="1.0" encoding="utf-8"?>
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
LinearLayout 加权重
首先设置Activity横屏显示,之后布局里把两个控件的宽度设成0dp,再分别设置两个相等的weight值
Imageview 宽设置成0dp后代码报错: width and height must be > 0 咋整、?
ImageView放到LinearLayout中 设置weight=1 然后图片放到LinearLayout中即可