मैं Google की नई डिज़ाइन समर्थन लाइब्रेरी के साथ खेल रहा हूं और यह एक विस्फोट है! नेविगेशन व्यू पर हालांकि मैं थोड़ा सा स्टंप हूं। मैंने जो कुछ भी पढ़ा है, वह कहता है कि NavigationView
अपने आप पारदर्शी scrim को संभालने के लिए पर्याप्त स्मार्ट है। (android-developers पोस्ट, एक के लिए; scrim के लिए खोज)। वैसे भी, यह करने के लिए जब मैं करने की कोशिश की मैं निम्नलिखित परिणाम प्राप्त:स्टेटस बार scrim के साथ अच्छा खेलने के लिए नया NavigationView कैसे प्राप्त करें?
कौन महान है; वास्तव में मैं क्या चाहता हूँ। एक चीज़ के अलावा। जब दराज बंद हो जाता है, तो स्किम एक बदसूरत गहरा भूरा होता है, न कि मेरे प्राथमिक कोलोर्डार्क। । ।
यहाँ मेरी लेआउट है:
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<fragment
android:id="@+id/fragment"
android:name="com.gmail.rixx.justin.envelopebudget.HomeFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_home" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/accent"
android:src="@drawable/ic_add_white_24dp" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
अभ्यास कोड:
public class Home extends ActionBarActivity {
private Toolbar mToolbar;
private DrawerLayout mDrawerLayout;
private Context mContext = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setUpToolbar();
setUpNavDrawer();
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(mContext, NewTransactionActivity.class));
}
});
}
private void setUpToolbar() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
if (mToolbar != null) {
setSupportActionBar(mToolbar);
}
}
private void setUpNavDrawer() {
if (mToolbar != null) {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mToolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawerLayout.openDrawer(GravityCompat.START);
}
});
}
}
@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_home, 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.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
और V21/शैलियों:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
मैं क्रिस बेंस के बाद मॉडलिंग की ' github पर पनीर स्क्वेयर ऐप लेकिन मुझे वह व्यवहार नहीं मिल रहा है जो मैं चाहता हूं।
मैं windowDrawsSystemBarBackgrounds
और statusBarColor
V21/शैलियों से दूर करने की कोशिश की है, और मैं उचित रंग मिलता है, लेकिन स्थिति पट्टी कभी नहीं पारदर्शी जाता है:
मदद की सराहना की जाएगी। यह नई चीजें है, इसलिए मुझे पता है कि हम सभी सीख रहे हैं।
पढ़ने के लिए धन्यवाद!
-Justin
yesss !!!! शुक्रिया शुक्रिया। मैं इसे घंटों के लिए देख रहा हूं। समर्थन और समर्थन डिजाइन पुस्तकालयों के लिए प्रलेखन खोजने के लिए बहुत मुश्किल हैं। मुझे लगता है कि बहुत सारी एंड्रॉइड सामग्री खराब दस्तावेज है। – Phil