Android开发,自定义AcrionBar
来源:互联网 发布:国外做博士后 知乎 编辑:程序博客网 时间:2024/05/16 09:02
<p>自定义ActionBar是进行开发肯定会遇到的一个步骤,谷歌给的Actionbar很难看,但是谷歌也给了开发者自行定义Actionbar的权利</p><p>首先建好要使用的AcrionBar界面,一般是LinearLayout的界面</p>
<?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="50dp" android:background="#CCCCCC" android:gravity="center_vertical" android:orientation="horizontal" > <ImageView android:id="@+id/ab_open_menu" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginLeft="10dp" android:background="@drawable/me" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="快递帮" android:gravity="center" android:layout_weight="1" android:textSize="16sp" /> <ImageView android:id="@+id/ab_write_info" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginRight="10dp" android:background="@drawable/set" /></LinearLayout>
然后在要导入的那个Main_Activity中进行更换
//自定义Actionbarfinal ActionBar actionBar = getActionBar();actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);actionBar.setCustomView(R.layout.my_actionbar);//导入自定义界面View actionbar_view = actionBar.getCustomView();ab_open_menu = (ImageView) actionbar_view.findViewById(R.id.ab_open_menu);//打开左侧菜单ab_write_info = (ImageView) actionbar_view.findViewById(R.id.ab_write_info);//打开书写界面//设置点击事件ab_open_menu.setOnClickListener(this);ab_write_info.setOnClickListener(this);
然后把具体的点击事件写好就好了
0 0
- Android开发,自定义AcrionBar
- Android开发:自定义字体
- Android开发 自定义ProgressBar
- 【android开发】自定义TabHost
- Android开发自定义View
- 【Android开发】自定义AlertDialog
- Android开发自定义Style
- Android 开发自定义View
- Android-开发自定义组件
- Android开发自定义popupwindow
- android开发 自定义广播
- Android开发-自定义toast
- Android开发 自定义popupwindow
- Android开发: View - 自定义
- Android开发自定义状态栏
- Android开发自定义View
- Android 开发 自定义Dialog
- Android 自定义 View 开发
- maven archetype:generate 的进一步理解
- iOS -- dismissViewControllerAnimated(Swift)
- html创建六边形区域
- Cypress固件架构彻底解析及USB枚举
- 基数排序
- Android开发,自定义AcrionBar
- Java中的类型转换
- LINUX驱动开发系列1 —— 内核模块
- hdfs dfs
- Centos Svn服务器搭建与配置
- springMVC请求参数接收方式
- souce insight使用不当,导致软件卡顿,没有响应。
- 用户空间和内核空间通讯之【Netlink 上】
- PHImageManager