2015-11-24 4 views
6

मैं नीचे दिए गए विज्ञापन को प्रदर्शित करने के लिए रिलेवेटिवआउट के साथ समन्वयक लेआउट का उपयोग कर रहा हूं। लेकिन मुझे जो मिल रहा है वह सफेद स्टेटस बार है। जब मैंने सापेक्ष लेआउट हटा दिया और सब कुछ ठीक काम करता है। जैसा कि मैं RelativeLayout के अंदर CoordinatorLayout लपेट रहा हूं जो मुझे मिलता है वह एक सफेद स्टेटस बार है। Status bar turns white and does not show content behind itगतिविधि लेआउट में Admob का उपयोग करते समय व्हाइट स्टेटसबार

लेआउट मैं इस्तेमाल किया जवाब यहाँ के समान दिखता है:

एपीआई v23 (मार्शमैलो)

का उपयोग करते हुए मैं भी यहाँ संबंधित सवाल पाया https://stackoverflow.com/a/31065486/1820644

लेकिन मुझे मदद की नहीं किया। मुझे अभी भी सफेद स्टेटसबार मिल रहा है।

मेरे activity_layout.xml फ़ाइल:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    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.testapp.EventActivity"> 

    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/adView"> 

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/appbar" 
      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:layout_scrollFlags="scroll|enterAlways" 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 

      <android.support.design.widget.TabLayout 
       android:id="@+id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

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

     <android.support.v4.view.ViewPager 
      android:id="@+id/container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="end|bottom" 
      android:layout_margin="@dimen/fab_margin" 
      android:src="@drawable/btn_plus_add" /> 

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

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="@string/banner_ad_test_id" /> 

</RelativeLayout> 

enter image description here

अग्रिम धन्यवाद!

उत्तर

10

लगभग सभी लेआउट, घोंसले लेआउट की कोशिश करने के बाद, जो काम आखिरकार काम करता था वह रूट के रूप में एक कोऑर्डिनेटर लेआउट डाल रहा था और विज्ञापन के ऊपर एक और समन्वयक लेआउट लगा रहा था।

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

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.CoordinatorLayout 
      .... 
      android:layout_above="@+id/adView"> 

      <android.support.v4.view.ViewPager 
       ... /> 

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

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      ... /> 

    </RelativeLayout> 

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

तो रूट के रूप में CoordinatorLayout के रूप में यह स्थिति बार रंग के बारे में सुनिश्चित करता है:

लेआउट पदानुक्रम जो मैं इस्तेमाल किया कुछ इस तरह है।

मैं क्या हासिल करने के लिए कोशिश कर रहा था गतिविधि लेआउट की जड़ तत्व के रूप में CoordinatorLayout और CoordinatorLayout की घोंसले के माध्यम से किया जाता है।

मेरी लेआउट फ़ाइल का पूर्ण कोड:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    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.testapp.EventActivity"> 

    <RelativeLayout 
     android:id="@+id/main_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.CoordinatorLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@+id/adView"> 

      <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:layout_scrollFlags="scroll|enterAlways" 
        app:popupTheme="@style/AppTheme.PopupOverlay" /> 

       <android.support.design.widget.TabLayout 
        android:id="@+id/tabs" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" /> 

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

      <android.support.v4.view.ViewPager 
       android:id="@+id/container" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

      <android.support.design.widget.FloatingActionButton 
       android:id="@+id/fab" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="end|bottom" 
       android:layout_margin="@dimen/fab_margin" 
       android:src="@drawable/btn_plus_add" /> 

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

     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="@string/banner_ad_bottom_event" /> 

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

यह अंततः होने के लिए बदल गया इस तरह दिखता है:

enter image description here

+0

यह एक भी समन्वयक लेआउट के साथ और सभी में कोई relativelayout साथ काम करता है। – Mikhail

संबंधित मुद्दे