android 自定义actionbar+字符串滚动显示
来源:互联网 发布:ping软件带地图 编辑:程序博客网 时间:2024/06/06 21:41
首先自定义TextView:
package com.android.myprojectdome.widget;import android.content.Context;import android.util.AttributeSet;import android.view.ViewDebug.ExportedProperty;import android.widget.TextView;public class ScrollTextView extends TextView {public ScrollTextView(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);// TODO Auto-generated constructor stub}public ScrollTextView(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stub}public ScrollTextView(Context context) {super(context);// TODO Auto-generated constructor stub}@Override@ExportedProperty(category = "focus")public boolean isFocused() {// TODO Auto-generated method stubreturn true;}}
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/lv_title_bg" android:layout_height="@dimen/actionbar_height" android:background="@android:color/black" > <com.android.myprojectdome.widget.ScrollTextView android:id="@+id/tv_title" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="@dimen/actionbar_title_padding" android:background="@android:color/transparent" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:gravity="center" android:singleLine="true" android:paddingEnd="8dp" android:textColor="@android:color/white" android:textSize="20sp" /> <View android:layout_width="fill_parent" android:layout_height="1dip" android:background="@color/line_color" android:layout_alignParentBottom="true"/></RelativeLayout>
然后再我们要用的activity里使用setActionBarLayout:
public void setActionBarLayout(int layoutId) {ActionBar actionBar = getActionBar();if (null != actionBar) {//actionBar.setDisplayHomeAsUpEnabled(false);actionBar.setDisplayShowHomeEnabled(false);actionBar.setDisplayShowCustomEnabled(true);LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);View v = inflator.inflate(layoutId, null);ActionBar.LayoutParams layout = new ActionBar.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);actionBar.setCustomView(v, layout);TextView tvTitle = (TextView) actionBar.getCustomView().findViewById(R.id.tv_title);RelativeLayout lv_title_bg = (RelativeLayout) actionBar.getCustomView().findViewById(R.id.lv_title_bg);lv_title_bg.setBackgroundColor(Color.BLACK);tvTitle.setText(R.string.action_settings);}}再在OnCreate()里调用:
setActionBarLayout(R.layout.setting_actionbar_layout);
0 0
- android 自定义actionbar+字符串滚动显示
- Actionbar 自定义多个TextView滚动显示
- android 自定义ActionBar后 启动项目会短暂显示默认ActionBar样式的问题
- Android自定义ActionBar
- Android自定义ActionBar
- Android Actionbar自定义标题栏
- android 自定义actionbar视图
- Android自定义ActionBar
- android 自定义 actionbar
- android ActionBar自定义样式
- android自定义的actionbar
- android actionbar 自定义样式
- android自定义actionBar布局
- Android ActionBar 自定义布局
- android ActionBar自定义CustomView
- Android自定义标题栏ActionBar
- android ActionBar自定义标题栏
- Android ActionBar高级自定义、
- 基于qualcomm平台的kinect教程四之获取骨骼图
- jsp 页面无法正确显示后台数据 ,需多次刷新才能正确显示 在springmvc
- SVM
- jetty https服务端-2
- WCF Restful调用跨域解决方案
- android 自定义actionbar+字符串滚动显示
- 2016-9-19
- 人工神经网络(ANN)
- MongoDb3配置简单远程连接-(无授权)即无需用户名密码来远程登录
- 【linux】centos oracle11G静默安装过程
- Max-Min Fairness 学习
- <s:submit>注意
- dijstra邻接表+堆优化模板
- oracle 操作表的sql