[英]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>
这是我的风格,我称这种风格为:
<application
android:name="com.lociiapp.LociiApplication"
android:allowBackup="true"
android:icon="@drawable/lokii_notification_icon"
android:theme="@style/Sherlock.__Theme" >
我的屏幕像这样:
我想在没有Locii文本且没有水平线和白色背景的情况下设置样式,但是我无法做到这一点,请向我建议如何实现此目的。
试试这种风格:
<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>
如果要删除标题,则可以删除:
android:label="@string/app_name"
在您的Manifest.xml中,或通过类似以下代码的方式进行操作:
getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
希望能帮助到你 :)
编辑
<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>
带代码:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
看来您想为自己的操作栏创建自己的布局。 这是一种解决方法。
在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>
然后,将其导入您的其他布局中:
<include
android:id="@+id/menu"
layout="@layout/menu" />
不要忘记隐藏操作栏或选择没有操作栏的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.