一. 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. RelativeLayout布局属性
  2. android中 menu的属性详细解释
  3. android 界面布局-各个布局的属性介绍
  4. Android View的属性
  5. android view的几种布局方式
  6. EditText属性大全
  7. Android 五种布局简单介绍
  8. 关于progressbar进度条的显示风格及一些属性的应用
  9. Android之TextView属性大全

随机推荐

  1. 【Android】使用LiveData KTX Builder让
  2. Android(安卓)Studio 一起走过的那些坑
  3. APIDEMO PREFERENCE 学习 ACTIVTIY
  4. Android下模拟按键输入
  5. 1. 0 Android(安卓)开发中的界面编程
  6. Android 获取存储卡路径和空间使用情况
  7. Android打开/关闭数据流量
  8. 实习杂记(27):android中关于横竖屏切换的那
  9. Android获取基带版本
  10. <转>android 中px,sp等的区别