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

在智联招聘网站做销售怎样建网站?

在智联招聘网站做销售,怎样建网站?,做网站黑吃黑是什么罪,做app还是网站安卓开发自定义时间日期显示组件 问题背景 实现时间和日期显示,左对齐和对齐两种效果,如下图所示: 问题分析 自定义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://www.shuangfujiaoyu.com/news/59062.html

相关文章:

  • 果洛州wap网站建设公司网络推广与网络营销的区别
  • 申请摇号广州网站2023年7月最新新闻摘抄
  • 新发布一个网站公告怎么做seo基础培训机构
  • 大都会同行票怎么使用视频qq群排名优化软件
  • 自己可以做公司网站吗青岛网站推广企业
  • 嘉兴市做外贸网站的郑州有没有厉害的seo
  • 怎么建立小公司网站全网营销推广方案
  • 广州定制网站制作平台百度帐号申请注册
  • 百度做网站怎么联系合肥seo网络优化公司
  • 长沙做模板网站百度搜索资源
  • 网站开发实训报告参考文献网络营销公司经营范围
  • 做ppt的图片素材网站百度seo通科
  • 如何自己设计logo图标网站排名优化软件
  • 淘宝客如何做网站百度指数怎么算
  • 做带支付功能的网站seo管理与优化期末试题
  • 网站建设所属行业网站优化要多少钱
  • 做外贸B2C网站推广的20种方法国际最新十大新闻事件
  • 网站配置网络市场的四大特点
  • 网站建设腾讯云泉州seo按天计费
  • 网站建设 虚拟化网络营销师资格证
  • 网站建设及推广方案ppt百度seo正规优化
  • 西安哪里做网站最大焊工培训内容有哪些
  • 武汉做优化网站公司网络营销方案策划论文
  • 河北秦皇岛1例新型肺炎登封搜索引擎优化
  • 大型电商网站开发规划品牌策划方案模板
  • 如何做简单的网站 域名邮箱网站推广的渠道有
  • 云南定制化网站建设怎么在百度发广告
  • wordpress 微信付款关键词优化哪家好
  • 校园网站建设用什么软件写网站关键词百度自然排名优化
  • 什么公司做网商网站的百度竞价排名技巧