View:layout_weight 权重 (数值越小,权重越大,默认为0)

博客围绕View:layout_weight权重展开,介绍其特点为值越小权重越大,默认值为0 。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       
根据上述功能,优化包含边框的悬浮窗布局文件 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:clipChildren="true" android:clipToPadding="true" android:orientation="vertical"> <View android:id="@+id/drag_top" android:layout_width="wrap_content" android:layout_height="14dp" android:visibility="gone" android:layout_gravity="top" android:background="@color/milu_orange" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <View android:id="@+id/drag_left" android:layout_width="14dp" android:layout_height="match_parent" android:visibility="gone" android:background="@color/milu_orange" /> <LinearLayout android:id="@+id/content_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:paddingBottom="10dp"> <LinearLayout android:id="@+id/ll_draggable" android:layout_width="25dp" android:layout_height="25dp" android:layout_centerVertical="true" android:gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@mipmap/ml_chat_draggable" /> </LinearLayout> <TextView android:layout_width="43dp" android:layout_height="3dp" android:layout_centerInParent="true" android:background="@drawable/botton_yuan_ef_5" /> <LinearLayout android:id="@+id/ll_close" android:layout_width="25dp" android:layout_height="25dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@mipmap/ml_bjlb_close" /> </LinearLayout> </RelativeLayout> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rlv_messagr" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="5" android:scrollbars="none" /> <TextView android:layout_width="wrap_content" android:layout_height="0dp" android:background="@drawable/bg_redius_transparent_75" android:paddingHorizontal="15dp" android:layout_weight="1" android:paddingVertical="5dp" android:text="说点什么吧" android:textColorHint="@color/milu_color_99" /> </LinearLayout> <View android:id="@+id/drag_right" android:layout_width="14dp" android:layout_height="match_parent" android:visibility="gone" android:background="@color/milu_orange" /> </LinearLayout> <LinearLayout android:id="@+id/ll_bottom" android:layout_width="match_parent" android:layout_height="14dp" android:visibility="gone" android:layout_gravity="left|bottom" android:orientation="horizontal"> <View android:id="@+id/drag_bottom_left" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/milu_orange" /> <View android:id="@+id/drag_bottom_right" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/milu_orange" /> </LinearLayout> </LinearLayout>
最新发布
07-03
<?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:orientation="horizontal" android:layout_width="match_parent" android:layout_height="100dp"> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:textSize="16sp"/> <TextView android:id="@+id/author" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:textColor="@color/gray"/> <TextView android:id="@+id/time" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:textColor="@color/gray"/> <TextView android:id="@+id/need" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:textColor="@color/gray"/> </LinearLayout> <com.google.android.material.button.MaterialButton android:layout_width="60dp" android:layout_height="100dp" android:layout_marginHorizontal="12dp" app:cornerRadius="6dp" android:textSize="20sp" android:text="报名" android:textStyle="bold"/> </LinearLayout> 如何解决Indicates how much of the extra space in the LinearLayout is allocated to the view associated with these LayoutParams. Specify 0 if the view should not be stretched. Otherwise the extra pixels will be pro-rated among all views whose weight is greater than 0.
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值