[英]how to set Custom Action bar in android
<style name="Sherlock.__Theme" parent="android:Theme.NoTitleBar">
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">@android:color/transparent</item>
</style>
this is my Style i am calling this Style Like this : 这是我的风格,我称这种风格为:
<application
android:name="com.lociiapp.LociiApplication"
android:allowBackup="true"
android:icon="@drawable/lokii_notification_icon"
android:theme="@style/Sherlock.__Theme" >
my screen come Like this : 我的屏幕像这样:
i want set style without Locii Text without Horizontal Line and with white background i am trying to do But unable to do this please suggest me how to Implement this . 我想在没有Locii文本且没有水平线和白色背景的情况下设置样式,但是我无法做到这一点,请向我建议如何实现此目的。
Try this style : 试试这种风格:
<style name="Sherlock.__Theme" parent="android:Theme.NoTitleBar">
<!-- Customize your theme here. -->
<item name="android:windowContentOverlay">@null</item>
<item name="android:background">#ffffff</item>
</style>
If you want to remove the tittle you can delete the : 如果要删除标题,则可以删除:
android:label="@string/app_name"
in your Manifest.xml, or do it by code like : 在您的Manifest.xml中,或通过类似以下代码的方式进行操作:
getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
Hope it helps :) 希望能帮助到你 :)
EDIT 编辑
<style name="Sherlock.__Theme" parent="android:Theme.NoTitleBar">
<!-- Customize your theme here. -->
<item name="android:windowContentOverlay">@null</item>
<item name="android:background">#ffffff</item>
<item name="displayOptions">showHome|useLogo</item>
</style>
With code : 带代码:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
it seems that you want to create your own layout for your action bar. 看来您想为自己的操作栏创建自己的布局。 Here is a way to to it. 这是一种解决方法。
In a menu.xml file, create your action bar 在menu.xml文件中,创建操作栏
<?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="wrap_content"
android:orientation="horizontal"
android:background="@color/custom"
android:gravity="center_vertical">
...
</LinearLayout>
Then, import it in your others layouts : 然后,将其导入您的其他布局中:
<include
android:id="@+id/menu"
layout="@layout/menu" />
Don't forget to hide the action bar or to select a theme without action bar. 不要忘记隐藏操作栏或选择没有操作栏的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.