किसी कारण से, स्टेटस बार अब सफेद है। या फिर, एक सफेद सफेद, सफेद रंग की एक और छाया के साथ चमकदार पृष्ठभूमि के खिलाफ बेहोश दिखाई देता है। जो गलत है, क्योंकि मेरा ऐपबारलेआउट नीले छाया का रंग के रूप में उपयोग करता है। अब तक, यह ठीक काम कर रहा है, मुझे नहीं पता कि मैंने इसका कारण क्या किया। मैंने मैन्युअल रूप से स्टेटसबारकोलर को रंगप्रिमडिर्क (# 0277bd) पर सेट करने का प्रयास किया है, लेकिन यह काम नहीं कर रहा है।एंड्रॉइड: स्टेटस बार व्हाइट
मुझे नहीं पता कि यह पहली जगह क्यों हो रहा है। मैं अपनी गतिविधि के लेआउट.एक्सएमएल को चिपका रहा हूं, शायद कोई मुझे यहां गलत तरीके से कर रहा है।
कुछ नोट:
इस्तेमाल किया विषयों को उनके डिफ़ॉल्ट, प्राथमिक रंग सेटिंग्स का उपयोग कर रहे हैं, जो बदली नहीं गई हैं। मैंने उन्हें नीले रंग की दाहिने छाया में बदल दिया जो मैं चाहता था, लेकिन जब मैंने यह परिवर्तन किया तो सबकुछ काम कर रहा था।
मेरे layout.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:statusBarColor="@color/colorPrimaryDark"
tools:context=".activities.ContactsActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/contactsActivityAppbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:statusBarColor="@color/colorPrimaryDark"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/contactsActivityToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
<!-- app:layout_scrollFlags="scroll|enterAlways" -->
<android.support.design.widget.TabLayout
android:id="@+id/contactsActivityTabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@android:color/white"
android:scrollbarStyle="insideOverlay"
android:paddingBottom="1dp"
android:background="@color/colorPrimary"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/contactsTabsViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#0288d1</color>
<color name="colorPrimaryDark">#0277bd</color>
<color name="colorAccent">#FF4081</color>
</resources>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
संपादित करें: ठीक है, एक दिलचस्प समाधान नहीं मिला, वास्तव में यह समझना चाहते हैं, बस उस पर भरोसा नहीं है। साथ ही, यह लंबे समय तक का सबसे अच्छा जवाब नहीं हो सकता है।
<item name="android:windowBackground">@color/colorPrimaryDark</item>
यह काम किया है, यह सब कुछ की पृष्ठभूमि है कि मैं विशेष रूप से एक रंग आवंटित नहीं किया, बनाया:
वैसे भी, styles.xml में आधार आवेदन विषय (AppTheme) करने के लिए, मैं निम्नलिखित लाइन जोड़ा वह रंग लेकिन इसने स्टेटस बार को रंग भी बनाया, इसलिए मैंने उन्हें ठीक करने के लिए अपनी चीजों को अन्य चीजों में जोड़ा और जोड़ा।
मुझे लगता है कि यह आदर्श समाधान नहीं है, हालांकि, और सामान्य रूप से अधिक प्रतिक्रिया पसंद करेंगे। इसके अलावा, यहां तक कि इस लाइन के बिना भी, यह स्टेटस बार को बस ठीक कर रहा था। मुझे नहीं पता कि मैंने इसे पहले स्थान पर तोड़ने के लिए क्या किया था।
धन्यवाद।
संपादित करें: यहां गतिविधि कोड है। धन्यवाद।
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import io.craigmiller160.contacts5.R;
import io.craigmiller160.contacts5.fragments.ContactsGroupsFragmentPage;
import io.craigmiller160.contacts5.fragments.ContactsListFragmentPage;
import io.craigmiller160.contacts5.fragments.ContactsTabsPagerAdapter;
public class ContactsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contacts);
Toolbar toolbar = (Toolbar) findViewById(R.id.contactsActivityToolbar);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.contactsTabsViewPager);
ContactsTabsPagerAdapter adapter = new ContactsTabsPagerAdapter(getSupportFragmentManager());
adapter.addFragmentPage(new ContactsListFragmentPage(), "Contacts");
adapter.addFragmentPage(new ContactsGroupsFragmentPage(), "Groups");
viewPager.setAdapter(adapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.contactsActivityTabs);
tabLayout.setupWithViewPager(viewPager);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.displaySettings) {
Intent intent = new Intent(this, DisplaySettingsActivity.class);
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(item);
}
}
बस उत्सुक। आपकी गतिविधि AppCompatActivity बढ़ाती है, है ना? – DavidH
क्या आप अपना मेनिफेस्ट और एक्टिविटी कोड भी पोस्ट कर सकते हैं? साथ ही, आपको अपने लेआउट xml से 'android: statusBarColor =" @ color/colorPrimaryDark "को हटा देना चाहिए। – DavidH
'एंड्रॉइड: फिट बैठता है सिस्टमविंडोज़ =" सत्य "'संदिग्ध है। यह एक पारदर्शी स्टेटसबार के साथ संयोजन में किया गया, स्टेटसबार के तहत गतिविधि या घटकों को चित्रित करने के लिए प्रयोग किया जाता है। यदि आपने कहीं से कोड के हिस्सों की प्रतिलिपि बनाई है, तो हो सकता है कि आपने कुछ ऐसा याद किया हो जो आपकी समस्या का कारण बन रहा हो। इसलिए, जैसा कि मैंने कहा, कृपया अपना गतिविधि कोड पोस्ट करें, या कम से कम केवल उन हिस्सों को जो आप सोचते हैं प्रासंगिक हैं। – DavidH