2016-04-06 1 views
0

Je crée une application Android et il y a une page comme ça, une page météo est maintenue à l'intérieur d'un tabhost:Masquer la barre d'action Android Studio à tabhost

Interface

La classe MainActivity:

public class MainActivity extends TabActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    //I used this but it's not working 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_main); 

    TabHost mTabHost = getTabHost(); 

    mTabHost.addTab(mTabHost.newTabSpec("first").setIndicator("First").setContent(
      new Intent(this, FirstActivity.class) 
    )); 
    mTabHost.addTab(mTabHost.newTabSpec("second").setIndicator("Second").setContent(
      new Intent(this, SecondActivity.class) 
    )); 
    mTabHost.setCurrentTab(0); 
} 

Et le SecondActivity contient le temps:

public class SecondActivity extends ActionBarActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

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

    setContentView(R.layout.activity_weather); 

    if (savedInstanceState == null) { 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.container, new WeatherFragment()) 
       .commit(); 
    } 


} 

Le problème est que je veux cacher la barre d'action <> car il semble vraiment horrible dans ce domaine. Comme vous pouvez le voir, j'ai essayé de demander FEATURE_NO_TITLE ou de définir FLAG_FULLSCREEN, ainsi que de définir android:theme="@style/Theme.AppCompat.NoActionBar" dans AndroidManifest, mais rien ne fonctionne bien.

(De plus, est-il possible de régler l'interface météo en plein écran? Comme il y a un petit espace entre les bords) Merci pour votre aide.

Répondre

0

Dans votre activité XML il y a une mise en page appelée appbarlayout s'il vous plaît supprimez-la, cela va fonctionner. dans mon activité xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.ezybzy.ezybzy.Categorypage"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/content_categorypage" /> 

</android.support.design.widget.CoordinatorLayout> 

s'il vous plaît changer à ce

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.ezybzy.ezybzy.Categorypage"> 



    <include layout="@layout/content_categorypage" /> 

</android.support.design.widget.CoordinatorLayout> 

cela ne fonctionnera que si vous créez une activité vide !!

+0

Cela n'a pas fonctionné, j'ai créé une activité vide à la place, donc il n'y a pas de