自定义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 ...
随机推荐
- Maven常见知识介绍
1)pom详解 2)pom详解 3)测试 4)插件与生命周期 5)maven生命周期 6)范围依赖
- SQLServer同一实例下事务操作
参考代码: 引用Dapper public bool OrderAdd2(User user, Order order) { string dbString = ConfigurationManage ...
- Openjudge 1.13-23:区间内的真素数
总时间限制: 1000ms 内存限制: 65536kB 描述 找出正整数 M 和 N 之间(N 不小于 M)的所有真素数. 真素数的定义:如果一个正整数 P 为素数,且其反序也为素数,那么 P 就 ...
- java 使用htmlunit模拟登录爬取新浪微博页面
mport java.io.IOException;import java.net.MalformedURLException;import com.gargoylesoftware.htmlunit ...
- HDU 6166 Senior Pan(多校第九场 二进制分组最短路)
题意:给出n个点和m条有向边(有向边!!!!我还以为是无向查了半天),然后给出K个点,问这k个点中最近的两点的距离 思路:比赛时以为有询问,就直接丢了,然后这题感觉思路很棒,加入把所有点分成起点和终点 ...
- C# Process.Start方法
System.Diagnostics.Process.Start(); 主要功能: 1.打开某个链接网址(弹窗). 2.定位打开某个文件目录. 3.打开系统特殊文件夹,如“控制面板”等. Proces ...
- currentStyle和getComputedStyle来获取外部样式
currentStyle和getComputedStyle来获取外部样式 通过document.getElementById(id).style.XXX就可以获取到XXX的值,但意外的是,这样做只能取 ...
- 数据库_6_SQL基本操作——库操作
SQL基本操作——库操作:对数据库的增删改查 一.新增数据库(创建) 基本语法:create database 数据库名字 [库选项]: 库选项用来约束数据库,分为两个选项:1.字符集设定:chars ...
- Android之父Andy Rubin:被乔布斯羡慕嫉妒的天才
今年中国掀起一股“苹果热”,智能手机iPhone.平板电脑iPad遭疯抢,一度卖断货.然而,令许多人意想不到的是,在“苹果”的老家——美国市场,智能手机中卖得最火的并不是iPhone,而是Androi ...
- Java数据结构面试题
1.栈和队列的共同特点是(只允许在端点处插入和删除元素) 4.栈通常采用的两种存储结构是(线性存储结构和链表存储结构) 5.下列关于栈的叙述正确的是(D) A.栈是非线性结构B.栈是一种树状 ...