2017-03-05 14 views
1

私はアプリを持っており、ログイン画面には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> 
を私のコードを見ていると、私が間違っているのか見てください

答えて

1

Nikaが言ったように、彼のアプローチは絶対に正しいです。あなたが見なければならないのは、2種類のテーマが作られていることです。 1つはAPI 21以上、もう1つは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> 

:以下のコードを参照し、それが助けたなら、私に知らせて...

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> 

あなたが必要とするこれをアクセスするために、マニフェストを次のように変更してください:

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

PS該当するAPIについてのテーマの表示方法がわからない場合はctrlボタンを押しながら "AppTheme.NoActionBar"テキストをクリックすると、それらのフィールドが見つかる2つのフィールドが表示され、両方のフィールドを編集するだけです。

+1

非常に詳細な回答仲間、ありがとうございました!ありがとう! –

+0

お疲れ様です!お力になれて、嬉しいです :) –

2

アクティビティのテーマを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> 
+0

私はAppTheme.NoActionBarを使用しました。私の電話の通知バーは白くなっています。 –

+0

AppCompatActivityを使用していますか? –

+0

はい、それは問題ですか? –

関連する問題