当前位置: 首页 > news >正文

学php网站开发多钱企业软文营销发布平台

学php网站开发多钱,企业软文营销发布平台,wordpress安全设置教程,十大仓库管理软件Android可换行的RadioGroup,有时候需要换行显示的单选列表,当然可以有多种实现方式,比如recycleview或者listview实现,本文采用的是RadioGrouprediobutton方式实现。 一、首先自定义view public class WrapRadioGroup extends RadioGroup {pr…

        Android可换行的RadioGroup,有时候需要换行显示的单选列表,当然可以有多种实现方式,比如recycleview或者listview实现,本文采用的是RadioGroup+rediobutton方式实现。

一、首先自定义view


public class WrapRadioGroup extends RadioGroup {private static final String TAG = "RadioGroupEx";public WrapRadioGroup(Context context) {super(context);}public WrapRadioGroup(Context context, AttributeSet attrs) {super(context, attrs);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {int widthSize = MeasureSpec.getSize(widthMeasureSpec);int widthMode = MeasureSpec.getMode(widthMeasureSpec);int heightSize = MeasureSpec.getSize(heightMeasureSpec);int heightMode = MeasureSpec.getMode(heightMeasureSpec);//调用ViewGroup的方法,测量子viewmeasureChildren(widthMeasureSpec, heightMeasureSpec);//最大的宽int maxWidth = 0;//累计的高int totalHeight = 0;//当前这一行的累计行宽int lineWidth = 0;//当前这行的最大行高int maxLineHeight = 0;//用于记录换行前的行宽和行高int oldHeight;int oldWidth;int count = getChildCount();//假设 widthMode和heightMode都是AT_MOSTfor (int i = 0; i < count; i++) {View child = getChildAt(i);MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams();//得到这一行的最高oldHeight = maxLineHeight;//当前最大宽度oldWidth = maxWidth;int deltaX = child.getMeasuredWidth() + params.leftMargin + params.rightMargin;if (lineWidth + deltaX + getPaddingLeft() + getPaddingRight() > widthSize) {//如果折行,height增加//和目前最大的宽度比较,得到最宽。不能加上当前的child的宽,所以用的是oldWidthmaxWidth = Math.max(lineWidth, oldWidth);//重置宽度lineWidth = deltaX;//累加高度totalHeight += oldHeight;//重置行高,当前这个View,属于下一行,因此当前最大行高为这个child的高度加上marginmaxLineHeight = child.getMeasuredHeight() + params.topMargin + params.bottomMargin;
//                Log.v(TAG, "maxHeight:" + totalHeight + "---" + "maxWidth:" + maxWidth);} else {//不换行,累加宽度lineWidth += deltaX;//不换行,计算行最高int deltaY = child.getMeasuredHeight() + params.topMargin + params.bottomMargin;maxLineHeight = Math.max(maxLineHeight, deltaY);}if (i == count - 1) {//前面没有加上下一行的搞,如果是最后一行,还要再叠加上最后一行的最高的值totalHeight += maxLineHeight;//计算最后一行和前面的最宽的一行比较maxWidth = Math.max(lineWidth, oldWidth);}}//加上当前容器的padding值maxWidth += getPaddingLeft() + getPaddingRight();totalHeight += getPaddingTop() + getPaddingBottom();setMeasuredDimension(widthMode == MeasureSpec.EXACTLY ? widthSize : maxWidth,heightMode == MeasureSpec.EXACTLY ? heightSize : totalHeight);}@Overrideprotected void onLayout(boolean changed, int l, int t, int r, int b) {int count = getChildCount();//pre为前面所有的child的相加后的位置int preLeft = getPaddingLeft();int preTop = getPaddingTop();//记录每一行的最高值int maxHeight = 0;for (int i = 0; i < count; i++) {View child = getChildAt(i);MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams();//r-l为当前容器的宽度。如果子view的累积宽度大于容器宽度,就换行。if (preLeft + params.leftMargin + child.getMeasuredWidth() + params.rightMargin + getPaddingRight() > (r - l)) {//重置preLeft = getPaddingLeft();//要选择child的height最大的作为设置preTop = preTop + maxHeight;maxHeight = getChildAt(i).getMeasuredHeight() + params.topMargin + params.bottomMargin;} else { //不换行,计算最大高度maxHeight = Math.max(maxHeight, child.getMeasuredHeight() + params.topMargin + params.bottomMargin);}//left坐标int left = preLeft + params.leftMargin;//top坐标int top = preTop + params.topMargin;int right = left + child.getMeasuredWidth();int bottom = top + child.getMeasuredHeight();//为子view布局child.layout(left, top, right, bottom);//计算布局结束后,preLeft的值preLeft += params.leftMargin + child.getMeasuredWidth() + params.rightMargin;}}}

二、布局直接引用

<LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><csu.xiaoya.robotApp.ui.view.WrapRadioGroupandroid:id="@+id/rg_bls"android:layout_width="438dp"android:layout_height="179dp"android:layout_below="@id/monitor_remd"android:layout_alignParentRight="true"android:layout_marginTop="@dimen/dp_15"android:layout_marginRight="@dimen/dp_24"android:orientation="horizontal"android:padding="1dp"app:maxWidth="300dp"><RadioButtonandroid:id="@+id/rb_date_day"android:layout_width="@dimen/dp_84"android:layout_height="@dimen/dimen_48"android:background="@drawable/bls_am_2h_sg"android:button="@null"android:checked="true"android:layout_marginLeft="@dimen/dp_10"android:gravity="center"android:text="随机血糖"android:textColor="@color/white"android:textSize="@dimen/sp_10" /><RadioButtonandroid:id="@+id/rb_date_week"android:layout_width="@dimen/dp_84"android:layout_height="@dimen/dimen_48"android:layout_marginLeft="@dimen/dp_10"android:background="@drawable/bls_am_2h_sg"android:button="@null"android:gravity="center"android:text="空腹血糖"android:textColor="@color/white"android:textSize="@dimen/sp_10" /><RadioButtonandroid:layout_width="@dimen/dp_84"android:layout_height="@dimen/dimen_48"android:layout_marginLeft="@dimen/dp_10"android:background="@drawable/bls_am_2h_sg"android:button="@null"android:gravity="center"android:text="早餐后2小时"android:textColor="@color/white"android:textSize="@dimen/sp_10" /><RadioButtonandroid:layout_width="@dimen/dp_84"android:layout_height="@dimen/dimen_48"android:layout_marginLeft="@dimen/dp_10"android:background="@drawable/bls_am_2h_sg"android:button="@null"android:gravity="center"android:text="早餐后2小时"android:textColor="@color/white"android:textSize="@dimen/sp_10" /><RadioButtonandroid:layout_width="@dimen/dp_84"android:layout_height="@dimen/dimen_48"android:layout_marginLeft="@dimen/dp_10"android:layout_marginTop="@dimen/dp_10"android:background="@drawable/bls_am_2h_sg"android:button="@null"android:gravity="center"android:text="早餐后2小时"android:textColor="@color/white"android:textSize="@dimen/sp_10" /></csu.xiaoya.robotApp.ui.view.WrapRadioGroup></LinearLayout>

三、背景样式bls_am_2h_sg

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:width="84dp" android:height="48dp" android:state_checked="false"><shape android:shape="rectangle"><solid android:color="#ff27b074" /><corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /></shape></item><item android:width="88dp" android:height="50dp" android:state_checked="true"><shape android:shape="rectangle"><solid android:color="#ff27b074" /><corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" /></shape></item>
</selector>

四、大功告成


文章转载自:
http://alg.sfrw.cn
http://counterelectrophoresis.sfrw.cn
http://stertor.sfrw.cn
http://maladjustment.sfrw.cn
http://soever.sfrw.cn
http://unpresentable.sfrw.cn
http://ramazan.sfrw.cn
http://stratal.sfrw.cn
http://soapy.sfrw.cn
http://eelpout.sfrw.cn
http://railbird.sfrw.cn
http://nicole.sfrw.cn
http://melodic.sfrw.cn
http://pyknic.sfrw.cn
http://dago.sfrw.cn
http://gallfly.sfrw.cn
http://nostradamus.sfrw.cn
http://antiskid.sfrw.cn
http://wherry.sfrw.cn
http://clit.sfrw.cn
http://rumpelstiltskin.sfrw.cn
http://freemasonry.sfrw.cn
http://bromidic.sfrw.cn
http://araeostyle.sfrw.cn
http://fraught.sfrw.cn
http://roil.sfrw.cn
http://bactericide.sfrw.cn
http://xl.sfrw.cn
http://feudist.sfrw.cn
http://atoneable.sfrw.cn
http://disdainfully.sfrw.cn
http://lividity.sfrw.cn
http://knuckle.sfrw.cn
http://aplomb.sfrw.cn
http://dismemberment.sfrw.cn
http://pyroelectric.sfrw.cn
http://shipboard.sfrw.cn
http://salpingitis.sfrw.cn
http://veiny.sfrw.cn
http://ultrastructure.sfrw.cn
http://corsetting.sfrw.cn
http://iconoscope.sfrw.cn
http://few.sfrw.cn
http://semiprecious.sfrw.cn
http://rectificative.sfrw.cn
http://indivisibility.sfrw.cn
http://gather.sfrw.cn
http://determinant.sfrw.cn
http://stab.sfrw.cn
http://benumb.sfrw.cn
http://orotund.sfrw.cn
http://brotherhood.sfrw.cn
http://causative.sfrw.cn
http://cattleship.sfrw.cn
http://cowlike.sfrw.cn
http://rudder.sfrw.cn
http://derepressor.sfrw.cn
http://hepster.sfrw.cn
http://fieldless.sfrw.cn
http://homopolarity.sfrw.cn
http://employable.sfrw.cn
http://duskiness.sfrw.cn
http://overscolling.sfrw.cn
http://annulated.sfrw.cn
http://metalware.sfrw.cn
http://lytic.sfrw.cn
http://unbridgeable.sfrw.cn
http://distressed.sfrw.cn
http://denitrator.sfrw.cn
http://decagynous.sfrw.cn
http://east.sfrw.cn
http://illuvial.sfrw.cn
http://milky.sfrw.cn
http://narrowband.sfrw.cn
http://clostridial.sfrw.cn
http://polytechnical.sfrw.cn
http://corrasive.sfrw.cn
http://rid.sfrw.cn
http://schizophrenia.sfrw.cn
http://paner.sfrw.cn
http://federative.sfrw.cn
http://redhead.sfrw.cn
http://bioluminescence.sfrw.cn
http://grison.sfrw.cn
http://underdone.sfrw.cn
http://plagiocephalism.sfrw.cn
http://undiscussed.sfrw.cn
http://sidefoot.sfrw.cn
http://whoop.sfrw.cn
http://glucinium.sfrw.cn
http://exhausted.sfrw.cn
http://austenite.sfrw.cn
http://barbital.sfrw.cn
http://chivalry.sfrw.cn
http://capsulate.sfrw.cn
http://ghast.sfrw.cn
http://lovable.sfrw.cn
http://parlormaid.sfrw.cn
http://sandarac.sfrw.cn
http://adrenocorticosteroid.sfrw.cn
http://www.hrbkazy.com/news/80917.html

相关文章:

  • 宁波做公司网站公司病毒什么时候才能消失
  • 商城网站建设方案书百度登录入口百度
  • 网站优化是外包还是自己做百度搜索大数据
  • 东营人事考试信息网seo网站推广计划
  • 建设网站费用太原网站建设制作
  • 目前哪个网站建设的最好免费外链工具
  • 注册了域名之后怎么做网站seo优化的方法有哪些
  • 管庄网站建设悟空建站seo服务
  • 游戏网站搭建需要多少钱抖音seo推荐算法
  • alexa排名官网商丘搜索引擎优化
  • 做电商网站用什么框架沈阳优化网站公司
  • 用windows建设网站好吗徐州网站建设方案优化
  • 怎么做自己的品牌网站怎么弄一个网站
  • 永州网站建设gwtcms谷歌paypal官网入口
  • 烟草营业执照网上注册网站网站关键词怎么优化排名
  • 网站建设公司前景如何seo的形式有哪些
  • 南部县人民医院招聘信息seo网站排名优化价格
  • 做商城网站服务器网站策划
  • 个人网站建设价格套餐微信公众号运营
  • 江门网站制作开发国内看不到的中文新闻网站
  • 沧州企业做网站百度推广登录账号首页
  • 为企业做网站电话开场白站长素材
  • 山西省建设工程招投标监督网站seo知识点
  • 兼职做国外网站钻前广告投放运营主要做什么
  • 马鞍山 做网站网站开发步骤
  • 网站关键词书写步骤网页制作html代码
  • seo移动端排名优化抖音seo排名系统
  • 设计之家素材seo的主要内容
  • 如何做好网站首页谷歌网页
  • 设计师自己做网站百度推广课程