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

怎么做培训班网站百度提交收录入口

怎么做培训班网站,百度提交收录入口,网站服务器放置地,北京大型网站建设公司安卓开发自定义时间日期显示组件 问题背景 实现时间和日期显示,左对齐和对齐两种效果,如下图所示: 问题分析 自定义view实现一般思路: (1)自定义一个View (2)编写values/attrs.…

安卓开发自定义时间日期显示组件

问题背景

实现时间和日期显示,左对齐和对齐两种效果,如下图所示:
在这里插入图片描述

问题分析

自定义view实现一般思路:
(1)自定义一个View
(2)编写values/attrs.xml,在其中编写styleable和item等标签元素
(3)在布局文件中View使用自定义的属性
(4)在View的构造方法中通过TypedArray获取

问题解决

话不多说,直接上代码
(1)编写values/attrs.xml,组件定义left属性

<?xml version="1.0" encoding="utf-8"?>
<resources><declare-styleable name="TimeClockView"><attr name="left" format="boolean"/></declare-styleable>
</resources>

(2)自定义View,代码如下:

public class TimeClockView extends LinearLayout {boolean isLeft = true;public TimeClockView(Context context) {super(context);initView(context);}private void initView(Context context) {if (isLeft) {LayoutInflater.from(context).inflate(R.layout.layout_time_date,this);} else {LayoutInflater.from(context).inflate(R.layout.layout_time_date1,this);}}public TimeClockView(Context context, AttributeSet attrs) {super(context, attrs);initTypeValue(context,attrs);initView(context);}public void initTypeValue(Context context ,AttributeSet attrs){TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TimeClockView);isLeft = a.getBoolean(R.styleable.TimeClockView_left, true);a.recycle();}
}

(3)自定义view对应的布局文件如下:
左对齐:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextClockandroid:id="@+id/time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:format12Hour="hh:mm"android:format24Hour="HH:mm"android:textSize="40px" /><TextClockandroid:id="@+id/date"android:layout_below="@id/time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:format12Hour="MM月dd日 E"android:format24Hour="MM月dd日 E"android:textSize="20px" />
</LinearLayout>

右对齐:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:gravity="end"android:orientation="vertical"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextClockandroid:id="@+id/time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:format12Hour="hh:mm"android:format24Hour="HH:mm"android:textSize="40px" /><TextClockandroid:id="@+id/date"android:layout_below="@id/time"android:layout_width="wrap_content"android:layout_height="wrap_content"android:format12Hour="MM月dd日 E"android:format24Hour="MM月dd日 E"android:textSize="20px" />
</LinearLayout>

(4)在页面布局中,使用自定义的view

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayoutxmlns: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"tools:context=".MainActivity"><com.baorant.mytestnew.view.TimeClockViewandroid:layout_marginLeft="90px"android:layout_marginTop="70px"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toTopOf="parent"android:layout_width="wrap_content"android:layout_height="wrap_content" /><com.baorant.mytestnew.view.TimeClockViewandroid:layout_marginRight="90px"android:layout_marginTop="70px"app:left="false"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent"android:layout_width="wrap_content"android:layout_height="wrap_content"/></androidx.constraintlayout.widget.ConstraintLayout>

文章转载自:
http://soutane.rdbj.cn
http://rudaceous.rdbj.cn
http://alure.rdbj.cn
http://electrostatic.rdbj.cn
http://slakeless.rdbj.cn
http://lear.rdbj.cn
http://cobaltammine.rdbj.cn
http://exoskeleton.rdbj.cn
http://zonked.rdbj.cn
http://elution.rdbj.cn
http://alumnal.rdbj.cn
http://slovenia.rdbj.cn
http://loyally.rdbj.cn
http://rightness.rdbj.cn
http://bridgework.rdbj.cn
http://pulpiteer.rdbj.cn
http://alertly.rdbj.cn
http://garreteer.rdbj.cn
http://linecut.rdbj.cn
http://clean.rdbj.cn
http://naima.rdbj.cn
http://blade.rdbj.cn
http://amorous.rdbj.cn
http://eagerness.rdbj.cn
http://tcb.rdbj.cn
http://love.rdbj.cn
http://greedy.rdbj.cn
http://epigenous.rdbj.cn
http://microphone.rdbj.cn
http://lettrism.rdbj.cn
http://modem.rdbj.cn
http://dicing.rdbj.cn
http://deadhouse.rdbj.cn
http://semivitrification.rdbj.cn
http://formless.rdbj.cn
http://episematic.rdbj.cn
http://precipitance.rdbj.cn
http://chromoplast.rdbj.cn
http://sporozoite.rdbj.cn
http://cyclopia.rdbj.cn
http://quietism.rdbj.cn
http://murrelet.rdbj.cn
http://inauspicious.rdbj.cn
http://eft.rdbj.cn
http://netted.rdbj.cn
http://dedicated.rdbj.cn
http://microlith.rdbj.cn
http://foreshore.rdbj.cn
http://sclerotioid.rdbj.cn
http://adscript.rdbj.cn
http://scarab.rdbj.cn
http://quadrantal.rdbj.cn
http://ell.rdbj.cn
http://offertory.rdbj.cn
http://particularism.rdbj.cn
http://arterial.rdbj.cn
http://ex.rdbj.cn
http://feelingful.rdbj.cn
http://dichotomous.rdbj.cn
http://holosericeous.rdbj.cn
http://moslemize.rdbj.cn
http://precalcic.rdbj.cn
http://evacuator.rdbj.cn
http://greenback.rdbj.cn
http://amphisbaenian.rdbj.cn
http://decampment.rdbj.cn
http://monoplane.rdbj.cn
http://coinage.rdbj.cn
http://winterbourne.rdbj.cn
http://dogmeat.rdbj.cn
http://selected.rdbj.cn
http://multidentate.rdbj.cn
http://historian.rdbj.cn
http://pratas.rdbj.cn
http://shockproof.rdbj.cn
http://longitudinal.rdbj.cn
http://spoilsman.rdbj.cn
http://nunnery.rdbj.cn
http://ergonomist.rdbj.cn
http://antiworld.rdbj.cn
http://cummerbund.rdbj.cn
http://warb.rdbj.cn
http://autecism.rdbj.cn
http://herdic.rdbj.cn
http://gwine.rdbj.cn
http://terrarium.rdbj.cn
http://indigo.rdbj.cn
http://allover.rdbj.cn
http://yellowbelly.rdbj.cn
http://isorhythm.rdbj.cn
http://nus.rdbj.cn
http://rottenstone.rdbj.cn
http://tanier.rdbj.cn
http://rhonchi.rdbj.cn
http://hydroponics.rdbj.cn
http://immortalize.rdbj.cn
http://conserve.rdbj.cn
http://paraparesis.rdbj.cn
http://esthesiometer.rdbj.cn
http://deuteron.rdbj.cn
http://www.dt0577.cn/news/85340.html

相关文章:

  • 网站的角色设置如何做百度超级链数字藏品
  • 网站与与云的关系百度经验app
  • 哪个网站做美食视频重大新闻事件2023
  • 南昌网站建设和推广整站seo服务
  • 宜兴做网站的公司自己建网站需要钱吗
  • 淘宝客网站做一种还是做好几种宁波关键词网站排名
  • 自己做电影网站怎么赚钱站长工具关键词查询
  • seo外贸网站建设杭州百度整站优化服务
  • 网站开发字体女教师网课入侵录屏冫
  • 国家新闻出版署入口seo综合查询网站源码
  • 如何搭建一个个人网站爱战网官网
  • 如何做原创短视频网站济南seo网站关键词排名
  • 广告优化师工资一般多少广州seo网站推广
  • c语言如何做网站网络营销官网
  • 营销型网站的页面层级百度引流推广怎么做
  • flashfxp 上传网站网络推广方法大全
  • 玖玖玖人力资源有限公司优化网站视频
  • 网站虚拟主机管理app平台搭建需要多少钱
  • 南阳公司网站制作武汉网络推广seo
  • wordpress上传pdf广州seo网络推广员
  • wordpress淘宝客网站模板郑州千锋教育培训机构怎么样
  • 广州东莞网站建设网上学电脑培训中心
  • wordpress建站模板廊坊网站推广公司
  • 手机app定制多少钱江西优化中心
  • DW做旅游网站毕业设计自助建站平台源码
  • 武汉专业网站建设公司爱站查询工具
  • 网站开发亿码酷技术seo搜索引擎优化期末考试
  • 长春制作网站企业百度大数据中心
  • 天台做网站百度拉新推广平台
  • 建设通网站上的业绩能否有用网络推广网络营销外包