如何使一个自定义的滴度栏不改变AppTheme到CustomTheme? [英] How to make a custom tite bar without changing the AppTheme to CustomTheme?

查看:284
本文介绍了如何使一个自定义的滴度栏不改变AppTheme到CustomTheme?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不喜欢CustomTheme看起来如何,我想保持AppTheme。

I dont like how the CustomTheme looks and I want to keep the AppTheme.

但是当我使用一个自定义标题栏与AppTheme崩溃告诉我,我不能结合样式繁多。

but when I use a customized title bar with AppTheme it crashes telling me I cant combine numerous styles.

我怎么能这样做?

谢谢!

推荐答案

首先箱子自己的自定义的动作条布局

First crate your own custom layout for the ActionBar

tab_header.xml

tab_header.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/header_title"
    android:textSize="18dp"
    android:layout_gravity="center"
    android:singleLine="true"
    android:maxLines="1"
    android:paddingLeft="@dimen/dim_10"
    android:paddingRight="@dimen/dim_10"
    android:textAllCaps="false"
    android:textColor="@color/white"
    />
   </LinearLayout>

然后在您电话的活动(有主页按钮启用)

Then in your Activity call (With Home Button Enabled)

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
    getActionBar().setCustomView(R.layout.tab_header);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

如果没有主页按钮

Without Home Button

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(R.layout.tab_header);

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);

这篇关于如何使一个自定义的滴度栏不改变AppTheme到CustomTheme?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆