奇怪的分隔与V7支持动作条 [英] Strange divider with the v7 support actionbar

查看:122
本文介绍了奇怪的分隔与V7支持动作条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所用的主题为动作条是 Theme.AppCompat.Light 在使用 Theme.Holo 的问题不存在。

我使用的是自定义视图的支持V7动作条:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@机器人:彩色/白>

< / LinearLayout中>
 

和我得到了以下结果:

我如何删除布局和动作条的黑线/分。

我试图改变的动作条的风格,但有没有太大的成功。

 <资源>

    <样式名称=Theme.Styled父=@风格/ Theme.AppCompat.Light>

        <! - 在Android命名空间中设置值会影响API等级14+  - >
        <项目名称=机器人:actionBarStyle> @风格/ Widget.Styled.ActionBar< /项目>
    < /风格>

    <样式名称=Widget.Styled.ActionBar父=@风格/ Widget.AppCompat.Light.ActionBar>
        <项目名称=dividerVertical> @空< /项目>
        <项目名称=机器人:背景> @空< /项目>
        <项目名称=机器人:paddingTop> 0dp< /项目>
        <项目名称=机器人:paddingBottom会> 0dp< /项目>
        <项目名称=机器人:showDividers>无< /项目>
        <项目名称=机器人:背景> @空< /项目>
        <项目名称=机器人:分> @空< /项目>
        <项目名称=机器人:dividerHeight> 0dp< /项目>
        <项目名称=机器人:dividerPadding> 0dp< /项目>
    < /风格>

< /资源>
 

下面是我的活动资料来源:

 公共类MainActivity扩展ActionBarActivity {

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);
        动作条动作条= getSupportActionBar();
        actionBar.setDisplayShowTitleEnabled(假);
        actionBar.setDisplayShowHomeEnabled(假);
        actionBar.setDisplayShowCustomEnabled(真正的);
        actionBar.setCustomView(R.layout.actionbar);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    }


}
 

这是明显的:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.example.actionbartest
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>

    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ Theme.Styled>
        <活动
            机器人:名称=com.example.actionbartest.MainActivity
            机器人:标签=@字符串/ APP_NAME
             >
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>

< /舱单>
 

解决方案

你可能寻找的<一个href="http://developer.android.com/reference/android/R.attr.html#windowContentOverlay"><$c$c>android:windowContentOverlay属性。

要删除阴影,只需将该值设置为 @null 在你的主题,像这样:

 &LT;样式名称=Theme.Styled父=@风格/ Theme.AppCompat.Light&GT;
    &LT;! - 在Android命名空间中设置值会影响API等级14+  - &GT;
    &LT;项目名称=机器人:actionBarStyle&GT; @风格/ Widget.Styled.ActionBar&LT; /项目&GT;

    &LT;项目名称=机器人:windowContentOverlay&GT; @空&LT; /项目&GT;
&LT; /风格&GT;
 

The used theme for the actionbar is Theme.AppCompat.Light when using Theme.Holo the issue does not exists.

I am using a custom view for the support v7 actionbar:

<?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="match_parent"
    android:background="@android:color/white" >

</LinearLayout>

And I get the following result :

How do I remove the black line/divider between the layout and the actionbar.

I have tried changing the actionbar style but with not much of a success.

<resources>

    <style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">

        <!-- Setting values in the android namespace affects API levels 14+ -->
        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
    </style>

    <style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
        <item name="dividerVertical">@null</item>
        <item name="android:background">@null</item>
        <item name="android:paddingTop">0dp</item>
        <item name="android:paddingBottom">0dp</item>
        <item name="android:showDividers">none</item>
        <item name="android:background">@null</item>
        <item name="android:divider">@null</item>
        <item name="android:dividerHeight">0dp</item>
        <item name="android:dividerPadding">0dp</item>
    </style>

</resources>

Here is my Activity Source:

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(R.layout.actionbar);
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

    }


}

This is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.actionbartest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Styled" >
        <activity
            android:name="com.example.actionbartest.MainActivity"
            android:label="@string/app_name"
             >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

解决方案

You're probably looking for the android:windowContentOverlay attribute.

To remove that drop shadow, simply set the value to @null in your theme, like so:

<style name="Theme.Styled" parent="@style/Theme.AppCompat.Light">
    <!-- Setting values in the android namespace affects API levels 14+ -->
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>

    <item name="android:windowContentOverlay">@null</item>
</style>

这篇关于奇怪的分隔与V7支持动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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