一. Android 修改actionbar的高度:

一直很纠结actionbar的高度该如何修改,现在就简单介绍一下,actionbar的高度由actionBarSize 属性决定,所以你你只要找到parent中带有该actionBarSize的属性,然后重新定义一个style就行了,例如:@android:style/Theme、@android:style/Theme.Holo、@android:style/Theme.Holo.Light 等。

1. style.xml代码贴上:

<span style="font-size:18px;"><resources xmlns:android="http://schemas.android.com/apk/res/android">    <style name="CustomTitleSize" parent="@android:style/Theme.Holo.Light">        <item name="android:actionBarSize">100dip</item>    </style></resources></span>

2. 在manifest.xml中的

<application
android:label="@string/app_name"
android:theme="@style/CustomTitleSize"
android:icon="@drawable/ic_launcher"
>

引用该样式,就可以达到修改actionbar的高度的目的。

注:android4.0里边有values-v11,values-v14两个文件夹分别对应的是android3.0和Andorid4.0以上,所以你可以根据不同的设备分别在文件夹里定义style.xml文件

二:解决Actionbar自定义标题栏不能填充满的问题:

// 自定义标题栏
getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowCustomEnabled(true);

//加载标题栏布局
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View mTitleView = mInflater.inflate(R.layout.custom_action_bar_layout,null);

//显示布局,通过这种方式你会发现宽度没有填充满父容器,解决之道:添加属性控制
getActionBar().setCustomView(mTitleView);

//显示布局,通过这种方式你会发现宽度可以正常填充满父容器
getActionBar().setCustomView(mTitleView,new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));

Actionbar属性讲解:http://blog.csdn.net/sunyouhao/article/details/7862017#

更多相关文章

  1. 转载:android 各种xml资源的引用方式
  2. android:layout_alignParentRight
  3. 自定义ListView中的分割线
  4. Android(安卓)View的属性
  5. android 界面布局-各个布局的属性介绍
  6. Android基础知识之Manifest文件的组织结构
  7. EditText属性大全
  8. android----UI组件
  9. 关于progressbar进度条的显示风格及一些属性的应用

随机推荐

  1. Android列表选择框Spinner使用方法详解
  2. android相对布局的几组属性
  3. 深入揭发:Android(安卓)的声音延迟
  4. Android系统篇之----Android中的智能指针
  5. android Spinner控件详解
  6. Android为什么卡顿系统原理分析
  7. Android(安卓)TTS学习——总结
  8. Android中实现并发性联网和数据访问
  9. intent.putExtra()方法参数详解
  10. AS(Android(安卓)Studio)开发开源Android库