2017-07-17 8 views
1

私はフルスクリーンのオーバーレイビューを表示しようとしています。まず、隠しオーバーレイでxmlをセットアップし、適切なときに表示します。ここに私のレイアウトは次のとおりです。ここでAppBarLayoutをオーバーラップするようにする

<?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_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appBar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary"/> 
    </android.support.design.widget.AppBarLayout> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/appBar" 
     android:textColor="#FFFFFF" 
     android:text="Hello World!" /> 

    <View 
     android:id="@+id/overlay" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clickable="true" 
     android:background="#80FF0000"/> 
</RelativeLayout> 

は結果である:

enter image description here

そして、私はそのようになる必要があります。だから、私は成功し、すべての重複してい

enter image description here

AppBarLayoutを除く画面。私のビューをAppBarLayoutの後ろに置かないようにするには?

+0

を@WhiteNinjaねえ、私の答えはあなたの問題を解決しているのですか? – Karoly

+0

@ Karoly、nope ..私の質問は、idが "overlay"のViewがAppBarLayoutと重複していないことと、それを修正する理由です。 – WhiteNinja

答えて

1

あなたの活動でこのコードを使用する必要があります。

public class MainActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    // If the Android version is lower than Jellybean, use this call to hide 
    // the status bar. 
    if (Build.VERSION.SDK_INT < 16) { 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
       WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    } 
    setContentView(R.layout.activity_main); 
} 
... 

}

をあなたはこの公式のGoogleのチュートリアルに従うことができます。 https://developer.android.com/training/system-ui/status.html

+0

この回答は私の質問ではありません...そして私のminSdkは19です – WhiteNinja

関連する問題