नई एंड्रॉइड समर्थन डिज़ाइन लाइब्रेरी का उपयोग करते समय मेरे ऐप में एक पारदर्शी स्टेटस बार सेट करने का प्रयास करते समय मुझे कुछ समस्याएं आ रही हैं।नई समर्थन डिज़ाइन लाइब्रेरी का उपयोग करते समय स्टेटस बार पारदर्शी नहीं है
विशेष रूप से, मैं संयोजन CoordinatorLayout
+ AppBarLayout
+ CollapsingToolbarLayout
+ Toolbar
इस श्रेणीबद्ध आदेश के साथ उपयोग कर रहा हूँ।
मैंने देखा कि स्टेटस बार पहले पारदर्शी आ गया है, तो मैं पारदर्शी से पूर्ण काला तक अनुवाद देख सकता हूं।
मैं मान/शैलियों में ऐसा करते हैं:
<item name="android:windowTranslucentStatus">true</item>
और ये मेरे लेआउट में:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="4dp"
android:background="?android:colorPrimary"
android:layout_width="match_parent"
android:layout_height="128dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="64dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardCornerRadius="4dp"
app:cardElevation="6dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Latest Stories"/>
<TextView
android:id="@+id/latest_story_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title Example"/>
<TextView
android:id="@+id/latest_story_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Content Example, this should be around 250 chars"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add_story"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"
app:borderWidth="0dp"
android:layout_margin="16dp"/>
<View
android:id="@+id/ripple_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:elevation="10dp"
android:stateListAnimator="@null"
android:clickable="false"/>
(भयानक प्रारूपण के लिए क्षमा करें, ऐसा लगता है अतः संपादक नहीं होगा सहयोग करें)
क्या इसे भविष्य में रिलीज में ठीक किया जाएगा या इसे बाईपास करने का एक तरीका है ?
सभी को धन्यवाद।
क्या आप getWindow() जोड़ रहे हैं। AddFlags (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)? http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_TRANSLUCENT_STATUS – krystian71115
धन्यवाद, यह काम करता है। मुझे कोड की इस पंक्ति से अवगत था, लेकिन मेरे कुछ अन्य ऐप्स में इसे किसी भी तरह की आवश्यकता नहीं थी। कृपया इसे एक उत्तर के रूप में लिखें ताकि मैं इसे स्वीकार कर सकूं! :) – Matteo