Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
应用程序顶部栏未隐藏android_Android_Android Manifest_Android Theme - Fatal编程技术网

应用程序顶部栏未隐藏android

应用程序顶部栏未隐藏android,android,android-manifest,android-theme,Android,Android Manifest,Android Theme,我有一个应用程序,在登录屏幕上我有多种登录方式,比如gmail、facebook和手动登录。它们都工作得很好,但当我试图隐藏显示应用程序名称的顶部栏时,问题出现了。我知道这与清单中的主题有关,但我没有设置任何主题。请看一下我的代码,看看我做错了什么 Manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/andr

我有一个应用程序,在登录屏幕上我有多种登录方式,比如gmail、facebook和手动登录。它们都工作得很好,但当我试图隐藏显示应用程序名称的顶部栏时,问题出现了。我知道这与清单中的主题有关,但我没有设置任何主题。请看一下我的代码,看看我做错了什么

Manifest.xml

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

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="23" />


<application
    android:allowBackup="true"
    android:icon="@drawable/the_spuck_4"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">


<activity android:name=".LoginActivity"/>

LoginActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.spuck.LoginActivity"
    style="@style/Red">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="94dp">


    <Button
        android:id="@+id/sign_in"
        android:layout_width="260dp"
        android:layout_height="35dp"
        android:textSize="13dp"
        android:text="Sign In"
        android:textColor="@color/white"
        android:textAllCaps="false"
        android:background="@drawable/signin_button_login_activity"
        android:gravity="center"
        android:layout_below="@+id/login_button"
        android:layout_alignLeft="@+id/sign_in_button"
        android:layout_alignStart="@+id/sign_in_button"
        android:layout_marginTop="33dp" />

    <ImageView
        android:id="@+id/app_name"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/the_spuck_3_2"
        android:background="@drawable/white_with_round"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp" />

    <com.google.android.gms.common.SignInButton
        android:id="@+id/sign_in_button"
        android:layout_width="260dp"
        android:layout_height="35dp"

        android:layout_marginTop="41dp"
        android:layout_below="@+id/app_name"
        android:layout_centerHorizontal="true" />

    <com.facebook.login.widget.LoginButton
        android:id="@+id/login_button"
        android:layout_width="255dp"
        android:layout_height="60dp"
        android:textColor="#ffffff"
        android:layout_marginTop="10dp"
        android:shadowColor="#000"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="10"
        android:layout_below="@+id/sign_in_button"
        android:layout_centerHorizontal="true" />
    </RelativeLayout>
</RelativeLayout>

AppTheme.NoActionBar.xml

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="colorPrimary">#ff5050</item>
    <item name="colorPrimaryDark">#ff5050</item>
</style>

假的
真的
#ff5050
#ff5050

将活动主题更改为
NoActionBar

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="colorPrimary">#ff5050</item>
    <item name="colorPrimaryDark">#ff5050</item>
</style>

假的
真的
#ff5050
#ff5050

正如尼卡所说,他的方法绝对正确。你需要看到的是有两种类型的主题。一个用于API 21及以上,另一个用于API 21及以下。你需要做的是将他说的主题分配给两个版本,因为你希望你的应用程序在两种API条件下都能工作。请参阅下面的代码,并让我知道它是否有帮助

对于API 21及以上版本:

<resources>

    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">#ff5050</item>
        <item name="colorPrimary">#ff5050</item>
        <item name="colorPrimaryDark">#ff5050</item>
    </style>
</resources>

假的
真的
真的
#ff5050
#ff5050
#ff5050
对于API 21及以下版本:

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="colorPrimary">#ff5050</item>
    <item name="colorPrimaryDark">#ff5050</item>
</style>

假的
真的
#ff5050
#ff5050
现在要访问此文件,您需要将清单更改为:

<activity android:name=".LoginActivity"
        android:theme="@style/AppTheme.NoActionBar"/>


p.S如果您不确定如何查看各自API的主题,请按住ctrl键并单击“AppTheme.NoActionBar”文本,它将向您显示两个字段,您可以在其中找到它们,并对它们进行编辑。

我使用了AppTheme.NoActionBar,现在我手机的通知栏已变为白色,有什么想法吗?你在使用AppCompatActivity吗?我无法将其更改为Activity,因为我正在使用google登录,它与Activity idk不起作用。whyNo,我问它只是为了确保。首选使用AppCompatActivity。请检查编辑。只是为了记录,在清单中我的活动应该是这样的:??非常详细的回答兄弟,非常感谢你的帮助和时间!谢谢