自定义Title
xml:
<jp.co.view.TitleLayout
android:id="@+id/titleLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
TitleLayout:
package jp.co.view import android.app.Activity
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import jp.co.hyakujushibank.securestarter.R class TitleLayout(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
private var barImg: ImageView? = null
private var titleTv: TextView? = null
private var closeTv: TextView? = null init {
LayoutInflater.from(context).inflate(R.layout.layout_title, this)
val activity = (getContext() as Activity)
val backImg = findViewById(R.id.backImg) as ImageView
val closeTv = findViewById(R.id.closeTv) as TextView
val titleTv = findViewById(R.id.titleTv) as TextView
val barImg = findViewById(R.id.barImg) as ImageView
this.barImg = barImg
this.titleTv = titleTv
this.closeTv = closeTv
backImg.setOnClickListener { activity.finish() }
} fun setBarImageResource(resource: Int) {
barImg!!.setImageResource(resource)
} fun setTitle(title: String) {
titleTv!!.text = title
} fun setCloseInvisible(){
closeTv!!.visibility=View.INVISIBLE
}
}
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <ImageView
android:id="@+id/backImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:src="@mipmap/back_black_btn" /> <jp.co.hyakujushibank.view.JapanTextBoldView
android:id="@+id/titleTv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="はじめに"
android:textSize="16dp" /> <jp.co.hyakujushibank.view.JapanTextBoldView
android:id="@+id/closeTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="中断する"
android:textSize="16dp" />
</LinearLayout> <View
android:id="@+id/lineView"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/color_EBEBEB" /> <ImageView
android:id="@+id/barImg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:src="@mipmap/nav_tab1" />
</LinearLayout>
自定义Title的更多相关文章
- Android 自定义title 之Action Bar
Android 自定义title 之Action Bar 2014-06-29 飞鹰飞龙... 摘自 博客园 阅 10519 转 25 转藏到我的图书馆 微信分享: Action Ba ...
- ecshop 全站自定义title标题
对于SEO来说,能让标题自定义的将会大大增加SEO效果,提高独立商城的流量,今天小编就收集从网上弄来ecshop全站自定义代码,很全哦! 1.Ecshop商品分类页如何实现自定义Title 最近发现很 ...
- Android 自定义title样式
requestWindowFeature(featrueId),它的功能是启用窗体的扩展特性.参数是Window类中定义的常量.一.枚举常量1.DEFAULT_FEATURES:系统默认状态,一般不需 ...
- ECSHOP商城全站自定义TITLE标题设置
对于SEO来说,能让标题自定义的将会大大增加SEO效果,提高独立商城的流量,今天小编就收集从网上弄来ecshop全站自定义代码,很全哦! 1.Ecshop商品分类页如何实现自定义Title 最近发现很 ...
- 转 Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature
自定义Titlebar时为了避免冲突 需要修改:AndroidManifest.xml android:theme="@style/mystyle" styles.xml文件中 ...
- android 自定义title
package com.xiangyu.su; import android.app.Activity; import android.os.Bundle; import android.view.V ...
- android 自定义title 报错 You cannot combine custom titles with other title feat
solution: http://www.apkbus.com/android-80416-1-1.html http://www.eoeandroid.com/forum.php?mod=viewt ...
- 原生HTML5 input type=file按钮UI自定义
原生<input type="file" name="file" />长得太丑 提升一下颜值 实现方案一.设置input[type=file]透明度 ...
- viewPager 的可滑动 Title
有三种方式: 1. 系统提供的title 缺点:标题在viewpager的滑动过程中也会滑动 实现:在ViewPager布局中添加 PagerTabStrip 或者是 PagerTitleStrip ...
随机推荐
- LINUX一网卡多IP设置
方法1:少量IP手动绑定(这里以绑定IP到eth0为例,其它网卡的话修改相应的文件名即可) 1.复制ifcfg-eth0的网卡配置文件并改名为ifcfg-eth0:0 [root@akinlau /] ...
- PHP识别二维码功能,php-zbarcode 安装
php-zbarcode是PHP识别二维码的扩展. 下面是安装方法,安装前要先安装ImageMagick.zbar. php-zbarcode 下载地址 安装ImageMagick: yum inst ...
- 将centos6的php5.3升级为5.6
在阿里云主机上,操作系统是Centos6,php版本是5.3.因为安装Yii2.0的需要,我要升级php为5.4.因为还有5.5和5.6,当然要升到高版本了.我决定升到5.6. 首先,按照这里的步 ...
- 【数据库-Azure SQL Database】SQL Server 如何将数据库备份到 Azure Storage
打开本地的 SQL Server Management Studio.首先创建 Credentials.命令如下: IF NOT EXISTS (SELECT * FROM sys.credent ...
- js对象引用的注意
var p = {}; var arr = []; function a(param) { // var i = param.a; for (var i = 0; i < 3; i++) { p ...
- MFC技术积累——基于MFC对话框类的那些事儿3
3.3.2 创建图形画刷来实现位图加载 1.首先在Resource View中导入一幅位图,位图大小96×96像素: 2.其次在主对话框中添加一个静态文本资源,ID号是IDC_BITMAPAREA,添 ...
- 兼容IE6\7\8浏览器的html5标签的几个方案
html5大行其道的时代已经到来.如果你还在等待浏览器兼容,说明你已经与web脱节几条街了.当然,这得益于移动客户端的蓬勃发展.如果还在纠结于,是否应该掌握html5和css3技术时,请狠狠的抽自己几 ...
- 洛谷 p1141 01迷宫题解
很长时间没发博客了,今天水一下 很多dalao说染色(普通的)过不了, 我怎么就过了 其实我也是今天才知道什么是染色(由@你听风在吼 dalao指导) 然后自己打了一个,也不知道叫不叫染色,反正是过了 ...
- luogu愚人节比赛划水记
先放链接:愚人节比赛 说好的 不毒瘤 呢?题目都太神奇了吧! 管理员的脑洞orz T1 这个可以说是蒙数据蒙出来的,直接输出"0",AC T2 本机房dalao成功发现" ...
- Web服务器☞Apache VS Nginx
Web服务器☞Apache VS Nginx LZ最近公司有一个项目在Web服务器选型上,在Apache和Nginx之间引起了一些讨论.这两者目前都是业内优秀的web服务器,都实现了HTTP1.1协议 ...