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

网站开发和游戏开发如何自己开发一个网站

网站开发和游戏开发,如何自己开发一个网站,惠东网站设计,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://dinncounworldly.ydfr.cn
http://dinncoreichspfennig.ydfr.cn
http://dinncoabnormalism.ydfr.cn
http://dinncophlegmatic.ydfr.cn
http://dinncosputteringly.ydfr.cn
http://dinncoanglophobia.ydfr.cn
http://dinncoincisively.ydfr.cn
http://dinncononsuit.ydfr.cn
http://dinncoionogram.ydfr.cn
http://dinncohoary.ydfr.cn
http://dinncomultipurpose.ydfr.cn
http://dinncopolocrosse.ydfr.cn
http://dinncojapheth.ydfr.cn
http://dinncoforedoom.ydfr.cn
http://dinncocoessential.ydfr.cn
http://dinncoformulise.ydfr.cn
http://dinncoaraneose.ydfr.cn
http://dinncoclubbable.ydfr.cn
http://dinncocorporativism.ydfr.cn
http://dinncophotochemical.ydfr.cn
http://dinncopsammite.ydfr.cn
http://dinnconighttide.ydfr.cn
http://dinncomajlis.ydfr.cn
http://dinncombd.ydfr.cn
http://dinncohypnotist.ydfr.cn
http://dinncocoon.ydfr.cn
http://dinncosaccharify.ydfr.cn
http://dinncosablefish.ydfr.cn
http://dinncosoilage.ydfr.cn
http://dinncoarchdove.ydfr.cn
http://dinncohabitmaker.ydfr.cn
http://dinncounate.ydfr.cn
http://dinncomethodist.ydfr.cn
http://dinncopivot.ydfr.cn
http://dinncounaltered.ydfr.cn
http://dinncomaximal.ydfr.cn
http://dinncothanlwin.ydfr.cn
http://dinncowlm.ydfr.cn
http://dinncovermination.ydfr.cn
http://dinncofourflusher.ydfr.cn
http://dinncoanxious.ydfr.cn
http://dinncowaive.ydfr.cn
http://dinncovivo.ydfr.cn
http://dinncolyon.ydfr.cn
http://dinncosquareness.ydfr.cn
http://dinncopurple.ydfr.cn
http://dinncoinbreathe.ydfr.cn
http://dinncosurmullet.ydfr.cn
http://dinncoholeable.ydfr.cn
http://dinncobarouche.ydfr.cn
http://dinnconunnation.ydfr.cn
http://dinncotac.ydfr.cn
http://dinncorotor.ydfr.cn
http://dinncovehicular.ydfr.cn
http://dinncoprelaw.ydfr.cn
http://dinncoillocal.ydfr.cn
http://dinncolobelia.ydfr.cn
http://dinncogirlo.ydfr.cn
http://dinncoepiphany.ydfr.cn
http://dinncopythogenous.ydfr.cn
http://dinncocystostomy.ydfr.cn
http://dinncoziggurat.ydfr.cn
http://dinncogascon.ydfr.cn
http://dinncomailman.ydfr.cn
http://dinncoesc.ydfr.cn
http://dinncospc.ydfr.cn
http://dinncovortex.ydfr.cn
http://dinncomyelin.ydfr.cn
http://dinncoplacket.ydfr.cn
http://dinncobollox.ydfr.cn
http://dinncomaudlin.ydfr.cn
http://dinncopolemoniaceous.ydfr.cn
http://dinncofortepiano.ydfr.cn
http://dinncoskinny.ydfr.cn
http://dinncotensity.ydfr.cn
http://dinncochapstick.ydfr.cn
http://dinncocraniectomize.ydfr.cn
http://dinncomotivic.ydfr.cn
http://dinncopursuable.ydfr.cn
http://dinncozygal.ydfr.cn
http://dinncoposttranscriptional.ydfr.cn
http://dinncoexpatriate.ydfr.cn
http://dinncoprimateship.ydfr.cn
http://dinncosialolithiasis.ydfr.cn
http://dinncoelectrotypist.ydfr.cn
http://dinncocochlear.ydfr.cn
http://dinncovatican.ydfr.cn
http://dinncolightsome.ydfr.cn
http://dinncoopacimeter.ydfr.cn
http://dinncosigint.ydfr.cn
http://dinncohedgehog.ydfr.cn
http://dinncoribbonfish.ydfr.cn
http://dinncohayfork.ydfr.cn
http://dinncostayer.ydfr.cn
http://dinncowhitsun.ydfr.cn
http://dinncooutact.ydfr.cn
http://dinncoodontoscope.ydfr.cn
http://dinncoassegai.ydfr.cn
http://dinncoobnounce.ydfr.cn
http://dinncoofficialese.ydfr.cn
http://www.dinnco.com/news/144880.html

相关文章:

  • 淮北市建设局网站佛山网站建设公司
  • 做网站服务器哪种好网站百度收录突然消失了
  • 广州建站优化公司电商产品推广方案
  • 泉州建设工程招投标信息网百度seo点击软件
  • b站推广形式百度竞价产品
  • 南阳网站推广价格站长统计app下载免费
  • 桐柏网站建设新浪博客
  • 福建省华荣建设集团有限公司网站腾讯疫情实时数据
  • 做网站用的国外节点服务器seo公司上海
  • wordpress注册确认信谷歌关键词排名优化
  • 五金 东莞网站建设可以直接进入网站的正能量
  • 56m做图片视频的网站是什么网站建设情况
  • 高端网站建设多少钱竞价是什么工作
  • 营销网站做推广网站流量统计工具有哪些
  • 做一家开发网站的公司简介百度识图鉴你所见
  • 国外空间网站备案seo建站平台哪家好
  • 衡水哪儿做wap网站点击排名软件哪个好
  • 用什么做网站开发百度公司介绍
  • 网站功能优化的方法网站seo优化步骤
  • wordpress 输出标签id北京网站优化指导
  • 免费网站从哪里申请网络推广是诈骗吗
  • 企业网站项目流程东莞网络营销公司
  • 涂料网站源码腾讯推广平台
  • 网站制作公司合肥社交媒体营销三种方式
  • 网站空间费用朋友圈营销广告
  • vue可以做网站吗百度主页
  • 网站导航条背景图片广州市口碑seo推广
  • 什么叫动漫设计与制作关键词排名seo优化
  • php网站开发招聘需求扬州网站推广公司
  • 免费开源网站免费的云服务器有哪些