如何从Android中的操作栏中删除divider?

时间:2015-05-18 06:34:40

标签: android android-actionbar android-custom-view

我正在整合操作栏的自定义视图。但是,我无法删除操作栏的分隔符。任何建议将不胜感激。感谢。

我在这样的清单中应用主题:

<application
        android:theme="@style/AppTheme"
        ...

内部themes.xml我有:

<style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:textColorPrimary">@color/mytheme_primary</item>
        <item name="android:textColorSecondary">@color/mytheme_secondary</item>
        <item name="android:textColorTertiary">@color/mytheme_tertiary</item>
        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
    </style>

<style name="AppTheme" parent="AppBaseTheme">
            <item name="android:windowActionBarOverlay">true</item>
            <item name="android:actionBarDivider">@android:color/transparent</item>
            <item name="android:ratingBarStyle">@style/RatingBarAppTheme</item>
            <item name="android:windowBackground">@android:color/transparent</item>
            <item name="android:colorBackgroundCacheHint">@null</item>
            <item name="android:actionBarStyle">@style/MyActionBar</item>
        </style>

        <!-- ActionBar styles -->
        <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@drawable/bg_action_bar</item>
            <item name="android:actionBarDivider">@android:color/transparent</item>
        </style>

虽然我将动作栏分隔符从两部分设置为透明,但似乎无论如何都不会生效:(

enter image description here

3 个答案:

答案 0 :(得分:1)

我之前遇到过同样的问题。 将windowContentOverlay设置为null将使其没有分隔符。

在你的样式xml文件中,输入:

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:actionBarDivider">@android:color/transparent</item>
        <item name="android:ratingBarStyle">@style/RatingBarAppTheme</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

并成为

{
   "error": {
      "message": "(#12) context field requires version v2.0 or higher",
      "type": "OAuthException",
      "code": 12
   }
}

答案 1 :(得分:0)

您应该将actionbarDivider添加到主Theme

<item name="android:actionBarDivider">@null</item> 

答案 2 :(得分:0)

只需添加活动

int

示例:

#include <iostream>

using namespace std;

int main() {
  int i;
  char x;

  RETRY:
  cout << "Please enter a number: ";
  cin >> i;
  if(!(cin >> i)){
    cin.clear();
    cin.ignore(10000, '\n');
    cout << "ERROR! ENTER A NUMBER!" << endl;
    cout << "Enter any character to continue: ";
    cin >> x;
    system("clear");
    goto RETRY;
  }

  cout << "Successful!";
}