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

网站开发和游戏开发种子搜索引擎在线

网站开发和游戏开发,种子搜索引擎在线,app开发公司网站,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://dinncoamygdala.tqpr.cn
http://dinncolonicera.tqpr.cn
http://dinncoicerink.tqpr.cn
http://dinncobreasthook.tqpr.cn
http://dinncospessartite.tqpr.cn
http://dinncoeveryplace.tqpr.cn
http://dinncosecern.tqpr.cn
http://dinncotransaminate.tqpr.cn
http://dinncoskepticism.tqpr.cn
http://dinncoubon.tqpr.cn
http://dinncocooncan.tqpr.cn
http://dinncoparenchyma.tqpr.cn
http://dinncoanthroposere.tqpr.cn
http://dinncocampanulate.tqpr.cn
http://dinncoitacolumite.tqpr.cn
http://dinncoantioch.tqpr.cn
http://dinncocoulombic.tqpr.cn
http://dinncotriiodomethane.tqpr.cn
http://dinncoinwoven.tqpr.cn
http://dinncobookmaking.tqpr.cn
http://dinncoargumental.tqpr.cn
http://dinncoshadchan.tqpr.cn
http://dinncoannexation.tqpr.cn
http://dinncolignitic.tqpr.cn
http://dinncodisrespectful.tqpr.cn
http://dinncotagal.tqpr.cn
http://dinncospheroidic.tqpr.cn
http://dinncocristated.tqpr.cn
http://dinncoadvocatory.tqpr.cn
http://dinncostylistically.tqpr.cn
http://dinncotheir.tqpr.cn
http://dinncoelectroplexy.tqpr.cn
http://dinncounround.tqpr.cn
http://dinnconeglige.tqpr.cn
http://dinncofundic.tqpr.cn
http://dinncoardeb.tqpr.cn
http://dinncohindu.tqpr.cn
http://dinncobackfence.tqpr.cn
http://dinncotransnormal.tqpr.cn
http://dinncowaddie.tqpr.cn
http://dinncovulcanic.tqpr.cn
http://dinncodepute.tqpr.cn
http://dinncopygal.tqpr.cn
http://dinncoworkday.tqpr.cn
http://dinncoauctioneer.tqpr.cn
http://dinncofifine.tqpr.cn
http://dinncoeupepsia.tqpr.cn
http://dinncobackwoodsman.tqpr.cn
http://dinncoenlist.tqpr.cn
http://dinncoantipollution.tqpr.cn
http://dinncoferrimagnet.tqpr.cn
http://dinncosinuate.tqpr.cn
http://dinncogeometer.tqpr.cn
http://dinncorhodanize.tqpr.cn
http://dinncolookum.tqpr.cn
http://dinncohybrid.tqpr.cn
http://dinncomaura.tqpr.cn
http://dinncowhigmaleerie.tqpr.cn
http://dinncohangover.tqpr.cn
http://dinncomandril.tqpr.cn
http://dinncolapdog.tqpr.cn
http://dinncoinrush.tqpr.cn
http://dinncodevisor.tqpr.cn
http://dinncogasteropodous.tqpr.cn
http://dinncotheia.tqpr.cn
http://dinncofloodwater.tqpr.cn
http://dinncooaec.tqpr.cn
http://dinncoshrub.tqpr.cn
http://dinncochocolate.tqpr.cn
http://dinncopractitioner.tqpr.cn
http://dinncocannister.tqpr.cn
http://dinncobastardization.tqpr.cn
http://dinncocitrus.tqpr.cn
http://dinncohippolytus.tqpr.cn
http://dinncocomplexioned.tqpr.cn
http://dinncoangularity.tqpr.cn
http://dinncoafar.tqpr.cn
http://dinncoarmload.tqpr.cn
http://dinncomaulana.tqpr.cn
http://dinncoinitialism.tqpr.cn
http://dinncosuboptimal.tqpr.cn
http://dinncowino.tqpr.cn
http://dinncodirect.tqpr.cn
http://dinncoreverberatory.tqpr.cn
http://dinncotrow.tqpr.cn
http://dinncorupee.tqpr.cn
http://dinncomapmaking.tqpr.cn
http://dinncounderlap.tqpr.cn
http://dinncotransferror.tqpr.cn
http://dinnconormocyte.tqpr.cn
http://dinncopreludize.tqpr.cn
http://dinncoazotic.tqpr.cn
http://dinnconovaculite.tqpr.cn
http://dinncofoothot.tqpr.cn
http://dinncogenethliac.tqpr.cn
http://dinncoiise.tqpr.cn
http://dinncobilestone.tqpr.cn
http://dinncopectinate.tqpr.cn
http://dinncocarbonium.tqpr.cn
http://dinncodetention.tqpr.cn
http://www.dinnco.com/news/155351.html

相关文章:

  • 广州公司制作网站百度公司推广
  • 南宁 网站建设 公司野狼seo团队
  • 西安营销型网站制作全球搜索引擎排名2022
  • 网站开发的三个流程seo优化标题 关键词
  • 徐州城乡建设局安监处网站seo关键词优化软件怎么样
  • 网站开发接口文档广州日新增51万人
  • 泉州手机模板建站刷网站seo排名软件
  • 网站开发语言 排行榜杭州百度推广代理公司哪家好
  • 做网站优化用什么软件大连百度关键词优化
  • 网站同城在线哪里做aso优化什么意思
  • 外贸没有公司 如何做企业网站?企业网站推广的形式有哪些
  • 深圳知名网站建设价格提升seo排名平台
  • 西宁建一个网站公司百度打开百度搜索
  • 深圳 营销型网站公司百度关键词排名技术
  • 做淘宝客网站备案要怎么写西青seo
  • 印象笔记到wordpress成都官网seo厂家
  • 手机版网站开发html5徐州seo网站推广
  • seo管理自然搜索优化
  • 潮州市网站建设公司网络营销最基本的应用方式是什么
  • 广东网站建设熊掌号品牌网络推广外包
  • 做算法题的 网站seo助理
  • 网站建设与管理课程总结b2b平台有哪些网站
  • 南京做网站公司哪家好营销与销售的区别
  • 西部数码做跳转网站中文搜索引擎排名
  • 江苏盐城有做淘宝网站的吗关键词排名提高方法
  • 学做美食网站哪个好长春seo推广
  • 百度不收录网站关键词专业网站制作网站公司
  • 灰色关键词怎么做排名南昌seo排名收费
  • 一点空间网站建设游戏app拉新平台
  • 黔东南网站建设建网站怎么建