Layout_width width 区别一例

本文详细介绍了在Android开发过程中遇到的一个常见问题:布局中控件宽度未按预期调整的情况。通过深入分析原因,作者发现是由于错误地使用了android:width属性而非通常使用的layout_width。文章提供了解决此问题的方法,并解释了layout_width与width属性的区别,包括warped_content的使用场景和限制。此外,还强调了在使用style时应注意的细节,以避免类似错误。
因为项目需要在我最新一个项目中用到了动态改变控件大小及位置等。
但刚刚突然发现有一个控件长度没有改变。 在仔细检查代码的时候发现原来使用的是 android:width 而非一直使用的layout_width (因使用了style故编译通过)。
在网络查看用发现width是可以指定具体数值,但layout_width其实也是可以的。
个人认为区别在:
1. layout_width为warp_content的时候 width可以再次限制一个最大值。
2. 也是今天出问题的原因。LayoutParement 中的width属性其实是layout_widtht指定的。

同理height layout_height也是一样的。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="match_parent" app:cardCornerRadius="8dp"> <!-- 数据卡片 --> <GridLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="2" android:padding="16dp" > <!-- 左侧网格(第一列) --> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <!-- 属性名 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="电机状态:" android:textStyle="bold" /> <View android:id="@+id/djStateO" android:layout_width="18dp" android:layout_height="18dp" android:layout_centerVertical="true" android:layout_marginRight="8dp" android:background="@drawable/circle_red" /> <!-- 属性值 --> <TextView android:id="@+id/djState" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="未使能" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <!-- 属性名 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="遥控器状态:" android:textStyle="bold" /> <View android:id="@+id/ykqStateO" android:layout_width="18dp" android:layout_height="18dp" android:layout_centerVertical="true" android:layout_marginRight="8dp" android:background="@drawable/circle_red" /> <!-- 属性值 --> <TextView android:id="@+id/ykqState" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="不在线" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <!-- 属性名 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="防撞条状态:" android:textStyle="bold" /> <View android:id="@+id/fztStateO" android:layout_width="18dp" android:layout_height="18dp" android:layout_centerVertical="true" android:layout_marginRight="8dp" android:background="@drawable/circle_green" /> <TextView android:id="@+id/fztState" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="无撞击" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <!-- 属性名 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="球蓝状态:" android:textStyle="bold" /> <View android:id="@+id/qlStateO" android:layout_width="18dp" android:layout_height="18dp" android:layout_centerVertical="true" android:layout_marginRight="8dp" android:background="@drawable/circle_green" /> <TextView android:id="@+id/qlState" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="未满" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <!-- 属性名 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SOC:" android:textStyle="bold" /> <TextView android:id="@+id/soc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="%" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="电压:" android:textStyle="bold" /> <TextView android:id="@+id/voltage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="V" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="电流:" android:textStyle="bold" /> <TextView android:id="@+id/electricity" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="A" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="车身状态:" android:textStyle="bold" /> <TextView android:id="@+id/carState" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="正常" android:layout_marginRight="8dp" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="左电机转速:" android:textStyle="bold" /> <TextView android:id="@+id/lMotorSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="右电机转速:" android:textStyle="bold" /> <TextView android:id="@+id/rMotorSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="遥控器左电机速度:" android:textStyle="bold" /> <TextView android:id="@+id/lYkqMotorSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="遥控器右电机速度:" android:textStyle="bold" /> <TextView android:id="@+id/rYkqMotorSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_columnWeight="1" android:orientation="horizontal" android:layout_marginBottom="8dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="报文:" android:textStyle="bold" /> <TextView android:id="@+id/txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:layout_marginRight="8dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </LinearLayout> </GridLayout> </androidx.cardview.widget.CardView> </LinearLayout> 这是我的安卓xml代码,我现在发现左边一行的数据过宽会影响到右边的数据,怎么修改,才能让数据过宽的时候自动换行,不影响整体一边一半的布局
最新发布
11-25
请用<!-- 支出类别选择图标组 --> <!-- 支出类别图标组 --> <LinearLayout android:id="@+id/expense_category_group_search_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="16dp"> <ImageButton android:id="@+id/category_food" android:layout_width="69dp" android:layout_height="wrap_content" app:srcCompat="@mipmap/hs_canyin_f" android:background="@color/button_default" /> <ImageButton android:id="@+id/category_shopping" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_gouwu_f" /> <ImageButton android:id="@+id/category_utilities" android:layout_width="69dp" android:layout_height="wrap_content" app:srcCompat="@mipmap/hs_shuidianfei_f" android:background="@color/button_default" /> <ImageButton android:id="@+id/category_phone" android:layout_width="69dp" android:layout_height="wrap_content" app:srcCompat="@mipmap/hs_tongxun_f" android:background="@color/button_default" /> <ImageButton android:id="@+id/category_entertainment" android:layout_width="69dp" android:layout_height="wrap_content" app:srcCompat="@mipmap/hs_yule_f" android:background="@color/button_default" /> </LinearLayout> <LinearLayout android:id="@+id/expense_category_group_search_2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="16dp"> <ImageButton android:id="@+id/category_other_outcome" android:layout_width="69dp" android:layout_height="wrap_content" app:srcCompat="@mipmap/hs_qt_f" android:background="@color/button_default" /> </LinearLayout> <!-- 收入类别图标组 --> <LinearLayout android:id="@+id/income_category_group_search_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="16dp" android:visibility="gone"> <ImageButton android:id="@+id/category_salary" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_xinzi_f" /> <ImageButton android:id="@+id/category_collect_debt" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_shouzhai_f" /> <ImageButton android:id="@+id/category_bonus" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_jiangjin_f" /> <ImageButton android:id="@+id/category_investment" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_touzi_f" /> <ImageButton android:id="@+id/category_accident" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_yiwaisuode_f" /> </LinearLayout> <LinearLayout android:id="@+id/income_category_group_search_2" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="16dp" android:visibility="gone"> <ImageButton android:id="@+id/category_other_income" android:layout_width="69dp" android:layout_height="wrap_content" android:background="@color/button_default" app:srcCompat="@mipmap/hs_qita_f" /> </LinearLayout> 代替<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="16dp"> <!-- 返回按钮 --> <Button android:id="@+id/back_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="返回" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> <!-- 标题 --> <TextView android:id="@+id/search_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="查询记录" android:textSize="24sp" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toStartOf="@id/back_button" /> <!-- 输入金额框 --> <EditText android:id="@+id/search_input" android:layout_width="0dp" android:layout_height="wrap_content" android:hint="金额" android:inputType="numberDecimal" android:digits="0123456789." android:textSize="16sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/by_amount_button" app:layout_constraintTop_toBottomOf="@id/search_title" android:layout_marginTop="16dp"/> <!-- 按金额查找按钮 --> <Button android:id="@+id/by_amount_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按金额查找" app:layout_constraintStart_toEndOf="@id/search_input" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/back_button" android:layout_marginStart="8dp"/> <!-- 收入/支出按钮 --> <Button android:id="@+id/income_button" android:layout_width="0dp" android:layout_height="wrap_content" android:text="收入明细" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/expense_button" app:layout_constraintTop_toBottomOf="@id/by_amount_button" android:layout_marginTop="16dp"/> <Button android:id="@+id/expense_button" android:layout_width="0dp" android:layout_height="wrap_content" android:text="支出明细" app:layout_constraintStart_toEndOf="@id/income_button" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/by_amount_button" android:layout_marginTop="16dp"/> <!-- 日期选择按钮 --> <Button android:id="@+id/date_picker_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="选择日期" app:layout_constraintTop_toBottomOf="@id/income_button" android:layout_marginTop="16dp"/> <!-- 类别单选组:两行三列布局 --> <RadioGroup android:id="@+id/category_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="8dp" app:layout_constraintTop_toBottomOf="@id/date_picker_button" android:layout_marginTop="16dp"> <RadioButton android:id="@+id/category_food" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="餐饮" /> <RadioButton android:id="@+id/category_shopping" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="购物" /> <RadioButton android:id="@+id/category_utilities" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="水电" /> <RadioButton android:id="@+id/category_phone" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="话费" /> <RadioButton android:id="@+id/category_entertainment" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="娱乐" /> <RadioButton android:id="@+id/category_other" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="其他" /> </RadioGroup> <!-- 查询结果表格 --> <ScrollView android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/category_group" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginTop="16dp"> <TableLayout android:id="@+id/result_table" android:layout_width="match_parent" android:layout_height="wrap_content" android:stretchColumns="*" /> </ScrollView> </androidx.constraintlayout.widget.ConstraintLayout> 的radiogroup部分
06-28
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff2f2f2" tools:context="com.hik.netsdk.SimpleDemo.View.MainActivity"> <RelativeLayout android:id="@+id/ra_title" android:layout_width="match_parent" android:layout_height="44dp" android:background="@mipmap/title_bg"> <TextView android:id="@+id/titlename" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_gravity="center" android:text="易丰视频监控" android:textColor="@android:color/white" android:textSize="18sp" /> <ImageButton android:id="@+id/back" android:layout_width="40dp" android:layout_height="match_parent" android:background="@null" android:contentDescription="@null" android:paddingLeft="10dp" android:contentDescription="视频插件" android:src="@mipmap/img_back" /> <ImageButton android:id="@+id/ib_rotate" android:layout_width="50dp" android:layout_height="match_parent" android:layout_alignParentRight="true" android:contentDescription="@null" android:onClick="changeScreen" android:layout_marginRight="6dp" android:scaleType="centerInside" android:background="@drawable/gps_select" android:contentDescription="视频插件" android:src="@mipmap/ic_size_sel" /> </RelativeLayout> <RelativeLayout android:id="@+id/rl_control" android:layout_width="match_parent" android:layout_height="266dp" android:layout_alignParentBottom="true" > <LinearLayout android:id="@+id/ll_center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerInParent="true" android:background="@mipmap/ycjk_yp" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb1" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb2" /> <ImageButton android:visibility="gone" android:id="@+id/left_up" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@null" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb3" /> </LinearLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb4" /> </LinearLayout> <ImageButton android:id="@+id/ptz_top_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/nnew_video_up" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb1" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb3" /> <ImageButton android:visibility="gone" android:id="@+id/right_up" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb2" /> </LinearLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb4" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" > <ImageButton android:id="@+id/ptz_left_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/nnew_video_left" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_zj" /> <ImageButton android:id="@+id/ptz_right_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/nnew_video_right" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb4" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb2" /> <ImageButton android:visibility="gone" android:id="@+id/left_down" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb3" /> </LinearLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb1" /> </LinearLayout> <ImageButton android:id="@+id/ptz_bottom_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/nnew_video_down" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb4" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb3" /> <ImageButton android:visibility="gone" android:id="@+id/right_down" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@null" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb2" /> </LinearLayout> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/ycjk_kb1" /> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_toLeftOf="@id/ll_center" android:gravity="center" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <ImageButton android:id="@+id/focus_add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:textSize="16dp" android:text="焦距 +" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/guangquan_add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more3" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:text="光圈 +" android:contentDescription="视频插件" android:textSize="16dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/zoom_add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more5" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:text="变倍 +" android:textSize="16dp" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_toRightOf="@id/ll_center" android:gravity="center" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/foucus_reduce" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more2" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:text="焦距 -" android:textSize="16dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/guangquan_reduce" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more4" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:text="光圈 -" android:contentDescription="视频插件" android:textSize="16dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center" android:orientation="vertical" > <ImageButton android:id="@+id/zoom_reduce" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more6" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/black" android:text="变倍 -" android:textSize="16dp" /> </LinearLayout> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_above="@id/rl_control" android:layout_below="@id/ra_title" android:layout_width="match_parent" android:layout_height="match_parent" > <SurfaceView android:id="@+id/realplay_sv" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" /> <ImageButton android:id="@+id/ib_rotate2" android:layout_width="40dp" android:layout_height="40dp" android:layout_alignParentLeft="true" android:layout_marginLeft="3dp" android:background="@color/green" android:contentDescription="@null" android:onClick="changeScreen" android:contentDescription="视频插件" android:src="@mipmap/img_systems_close" /> <ProgressBar android:id="@+id/liveProgressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> <LinearLayout android:id="@+id/ll_hc" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" > <ImageButton android:id="@+id/ptz_top_btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/h_up" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" > <ImageButton android:id="@+id/ptz_bottom_btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/h_down" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" > <ImageButton android:id="@+id/ptz_left_btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/h_left" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" > <ImageButton android:id="@+id/ptz_right_btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@mipmap/h_right" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:gravity="center" android:layout_weight="1" > <ImageButton android:id="@+id/focus_add2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more1" /> </LinearLayout> <LinearLayout android:gravity="center" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/foucus_reduce2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more2" /> </LinearLayout> <LinearLayout android:gravity="center" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/zoom_add2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more5" /> </LinearLayout> <LinearLayout android:gravity="center" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > <ImageButton android:id="@+id/zoom_reduce2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:contentDescription="视频插件" android:background="@drawable/video_more6" /> </LinearLayout> </LinearLayout> </RelativeLayout> </RelativeLayout> 依据上述代码解决报错:ptz_right_btn <ImageButton>: Touch target size too small <ImageButton>: Touch target size too small ptz_bottom_btn <ImageButton>: Touch target size too small
06-24
那你帮我在这个基础上进行最小量的修改<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/surface_background"> <!-- 🔹 上方搜索栏容器 --> <LinearLayout android:layout_marginTop="?attr/actionBarSize" android:id="@+id/search_container" android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="8dp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintWidth_percent="0.95" /> <!-- EditText 输入框 --> <EditText android:id="@+id/search_input" android:layout_width="0dp" android:layout_height="48dp" android:layout_weight="1" android:hint="搜索公交站或线路" android:padding="12dp" android:background="@drawable/rounded_edittext" android:layout_marginEnd="8dp" android:inputType="text" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@id/search_btn" app:layout_constraintTop_toTopOf="@id/search_container" app:layout_constraintBottom_toBottomOf="@id/search_container" /> <!-- 搜索按钮 --> <Button android:id="@+id/search_btn" android:layout_width="wrap_content" android:layout_height="48dp" android:text="搜索" app:layout_constraintStart_toEndOf="@id/search_input" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@id/search_container" app:layout_constraintBottom_toBottomOf="@id/search_container" /> <!-- 🗺️ 地图视图:占页面中间 40% 高度 --> <com.amap.api.maps.MapView android:id="@+id/map_view" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/search_container" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_percent="0.4" app:layout_constraintWidth="wrap_content" android:layout_marginTop="10dp" android:layout_marginHorizontal="16dp" /> <!-- 🔽 RecyclerView:结果列表,占据剩余空间 --> <androidx.recyclerview.widget.RecyclerView android:id="@+id/result_list" android:layout_width="0dp" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/map_view" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@id/btn_go_to" app:layout_constraintVertical_bias="0" android:layout_marginTop="8dp" android:layout_marginHorizontal="16dp" /> <!-- “到这去”按钮:固定在底部上方 --> <Button android:id="@+id/btn_go_to" android:layout_width="0dp" android:layout_height="wrap_content" android:text="到这去" android:layout_margin="16dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> 用guidelinespace的结合给我提供一份完整代码
11-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值