Android自定义操作栏未显示

时间:2015-09-18 05:17:05

标签: android android-actionbar themes

我的父主题是Theme.AppCompat.Light.DarkActionBar,我添加了  在清单文件中并为具有不同颜色但不是全部的操作栏创建自定义style.xml,操作栏不可见我该怎么办?我正在使用android studio和lolipop版本。

style.xml

public class Node 
    {
        private String name;
        private List<String> dependencies;
        private List<String> dependees;

        /// <summary>
        /// construct a new Node by passing in a name and lists for both the dependencies and the dependees
        /// </summary>
        /// <param name="_name"></param>
        /// <param name="_dependencies"></param>
        /// <param name="_dependees"></param>
        public Node(String _name, List<String> _dependencies, List<String> _dependees)
        {
            name = _name;
            dependencies = _dependencies;
            dependees = _dependees;
        }

        /// <summary>
        /// construct a Node with just a name and blank dependent lists
        /// </summary>
        /// <param name="_name"></param>
        public Node(String _name)
        {
            name = _name;
            dependencies = new List<string>();
            dependees = new List<string>();
        }

        /// <summary>
        /// getter for the dependencies property
        /// </summary>
        public List<String> getDependencies()
        {
            return this.dependencies;
        }
    }

的manifest.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowActionBar">true</item>
</style>

<style name="CustomActionBarTheme"
    parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>

</style>
<style name="MyActionBar"
    parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:background">#800000</item>
</style>

3 个答案:

答案 0 :(得分:0)

使用 Theme.AppCompat.Light.NoActionBar 并在主布局中创建工具栏布局。在活动中绑定工具栏和

<强> setSupportActionbar(栏);

从此处阅读工具栏部分:https://chris.banes.me/2014/10/17/appcompat-v21/

答案 1 :(得分:0)

不应使用rpc_server = zmq.Context.instance().socket(zmq.REP) rpc_server.curve_secretkey = server_secret rpc_server.curve_publickey = server_public rpc_server.curve_server = True # must come before bind rpc_server.bind(rpc_endpoint) rpc_stream = zmqstream.ZMQStream(rpc_server) rpc_stream.on_recv_stream(self.echo) 定义自定义styles.xml,而应使用Android Official guide

中记录的ActionBar

取自Android development's Official guide

的示例
themes.xml

在您的清单文件中,您可以将主题应用于整个应用:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabTextStyle">@style/TabTextStyle</item>
    <item name="android:actionMenuTextColor">@color/actionbar_text</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabTextStyle">@style/TabTextStyle</item>
    <item name="actionMenuTextColor">@color/actionbar_text</item>
</style>

<!-- general styles for the action bar -->
<style name="MyActionBar"
       parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/TitleTextStyle</item>
    <item name="android:background">@drawable/actionbar_background</item>
    <item name="android:backgroundStacked">@drawable/actionbar_background</item>
    <item name="android:backgroundSplit">@drawable/actionbar_background</item>

    <!-- Support library compatibility -->
    <item name="titleTextStyle">@style/TitleTextStyle</item>
    <item name="background">@drawable/actionbar_background</item>
    <item name="backgroundStacked">@drawable/actionbar_background</item>
    <item name="backgroundSplit">@drawable/actionbar_background</item>
   </style>
</resources>

或个人活动:

<application android:theme="@style/CustomActionBarTheme" ... />

答案 2 :(得分:0)

我找到了

的解决方案
  1. 添加支持库:
  2. enter image description here

    1. 扩展AppCompatActivity类
    2. 将代码添加到build.gradle
    3. buildTypes {

          debug {
      
              minifyEnabled true
          }
      
          release {
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      
          }
      }
      

      现在它的工作f9。 谢谢