Theme.Light.NoTitleBar中的这个顶部边框来自哪里?

Ami*_*far 2 android

我有以下application.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.currency.mobile.android">
    <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name"
                 android:theme="@android:style/Theme.Light.NoTitleBar">

        <activity android:name=".MainActivity" android:noHistory="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name=".LoginActivity"/>
        <activity android:name=".HomeActivity" />
        <activity android:name=".FriendsActivity"/>
        <activity android:name=".PlacesActivity"/>
        <activity android:name=".ProfileActivity"/>
        <activity android:name=".PurchasesActivity"/>
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

这是我的标签视图:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@android:id/tabhost"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
        <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
        <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="5dp"/>
    </LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)

当使用Theme.Light.NoTitleBar时,我在中间得到了这条丑陋的线条:

替代文字

但是当我使用Theme.Black时,它没有这么奇怪的界限.有什么方法可以解决它,以便我可以使用轻主题?

Yon*_*lan 5

这实际上是主题的框架(或者可能是叠加,我永远不会记得哪一个具体),并且Android将它应用于活动,即使它们嵌套在标签内.关键是要设定的主题(在res/value/theme.xml)与windowFramewindowContentOverlay属性设置为@null在所述容器的活动,像这样的:

<style
    name="Theme.Light.NoFrame"
    parent="android:Theme.Light">
    <item
        name="android:windowFrame">@null</item>
    <item
        name="android:windowContentOverlay">@null</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我还建议在AOSP中挖掘style.xml和theme.xml以了解更多信息; 主题和样式严重缺乏文档,但只需阅读源代码就很容易理解.