2016-10-04 9 views
2

スプラッシュスクリーンを作成しようとしていますが、フルスクリーン、ツールバーなし、スプラッシュスクリーンのテーマをフルスクリーンとデザインビューに変更しましたすべてが完璧だと思われますが、エミュレータでアプリを起動するとツールバーが再び表示されます。howtoはアンドロイドスタジオでフルスクリーンアクティビティを取得します

マイandroidmenifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.shiftind.www.shiftind"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity android:name=".SplashScreen"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
      android:label="@string/app_name" 
      android:launchMode="singleTask" 
      android:theme="@style/Theme.AppCompat.Light.NoActionBar" 
      android:screenOrientation="landscape" > 
     </activity> 
     <activity android:name=".MainActivity"></activity> 
     <activity android:name=".registration" /> 
     <activity android:name=".login" /> 
     <activity android:name=".SignUp" /> 
    </application> 

</manifest> 

*My splashscreen.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" 
    android:id="@+id/activity_splash_screen" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.shiftind.www.shiftind.SplashScreen" 
    android:background="@drawable/shiftind"> 



</RelativeLayout> 

マイSplashScreen.javaあなたAndroidManifestが壊れていた

package com.shiftind.www.shiftind; 

import android.content.Intent; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class SplashScreen extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash_screen); 
     Thread MyThread = new Thread(){ 
      @Override 
      public void run() { 
       try { 
        sleep(3000); 
        Intent intent = new Intent(getApplicationContext(), MainActivity.class); 
        startActivity(intent); 
        finish(); 
       } catch (InterruptedException e) { 
        e.printStackTrace(); 
       } 
      } 
     }; 
     MyThread.start(); 
    } 
} 
+0

多分これ:-)してくださいまだコメントの混乱の記載がある場合

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> </resources> 

以下のように、あなたのスタイルのonCreateメソッド

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

で、あなたのセット内のコード以下の活動の使用において

トピックはあなたを助けることができます:http://stackoverflow.com/questions/2868047/fullscreen-activity-in-android? – Berger

答えて

0

、ここにいるの訂正:

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".SplashScreen" 
     android:label="@string/app_name" 
     android:launchMode="singleTask" 
     android:theme="@style/Theme.AppCompat.Light.NoActionBar" 
     android:screenOrientation="landscape" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".MainActivity"></activity> 
    <activity android:name=".registration" /> 
    <activity android:name=".login" /> 
    <activity android:name=".SignUp" /> 
</application> 

+0

それは動作しませんでした –

3

テーマを手動で定義し、そこでプロパティを設定してみてください。 themes.xmlで:

<style name="MyThemeNoBar" parent="@style/Theme.AppCompat.Light"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

そしてAndroidManifest.xmlに、にスプラッシュ画面のテーマを設定:編集

android:theme="@style/MyThemeNoBar" 

:私はまたandroid:windowFullscreenandroid:windowContentOverlay(ソース:https://stackoverflow.com/a/25365193/3474282)を追加しました

+0

それは動作しませんでした –

+0

私はちょうどいくつかのおそらく有用なプロパティを追加しました – AJR

0

ますプログラムでこれを行うことができます(see android samples):

public void toggleHideyBar() { 
    // The UI options currently enabled are represented by a bitfield. 
    // getSystemUiVisibility() gives us that bitfield. 
    int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility(); 
    int newUiOptions = uiOptions; 
    boolean isImmersiveModeEnabled = 
      ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); 
    if (isImmersiveModeEnabled) { 
     Log.i(TAG, "Turning immersive mode mode off. "); 
    } else { 
     Log.i(TAG, "Turning immersive mode mode on."); 
    } 

    // Immersive mode: Backward compatible to KitKat (API 19). 
    // Note that this flag doesn't do anything by itself, it only augments the behavior 
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample 
    // all three flags are being toggled together. 
    // This sample uses the "sticky" form of immersive mode, which will let the user swipe 
    // the bars back in again, but will automatically make them disappear a few seconds later. 
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; 
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; 
    getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions); 
} 
0

私の場合、私の要件を満たす以下のものを使用しています!

関連する問題