मैं एंड्रॉइड लॉलीपॉप (5.0) में इस्तेमाल किए गए नए मटीरियल डिज़ाइन के साथ एक ऐप बना रहा हूं।
मैं निम्नलिखित गाइड का उपयोग कर रहा हूं:
- http://android-developers.blogspot.it/2014/10/appcompat-v21-material-design-for-pre.html
- http://antonioleiva.com/material-design-everywhere/
अपना टूलबार बनाने के बाद, मुझे यह त्रुटि मिलती है: "निम्नलिखित कक्षाएं त्वरित नहीं हो सकीं: - android.support.v7.widget.Toolbar"
ऐप फोन या एमुलेटर में अच्छा काम करता है, लेकिन एंड्रॉइड स्टूडियो का लेआउट डिजाइनर लेआउट को सही ढंग से नहीं दिखाता है।
यहाँ कुछ चित्र हैं:
My_awesome_toolbar.xml लेआउट पूर्वावलोकन में त्रुटि

Activity_my.xml लेआउट पूर्वावलोकन में त्रुटि

फ़ाइलों का xml कोड:
my_awesome_toolbar.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
activity_my.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root"
tools:context="com.myapp.test.MyActivity"
android:orientation="horizontal">
<include
android:id="@+id/toolbar"
layout="@layout/my_awesome_toolbar"
/>
<!-- Rest of layout -->
</RelativeLayout>
MyActivity.java:
package com.myapp.test;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
public class MyActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, 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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
शैलियों का xml कोड (मान / स्टाइल। xml):
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/blue</item>
<item name="colorPrimaryDark">@color/dark_blue</item>
<item name="actionOverflowButtonStyle">@style/AppTheme.OverflowButtonStyle</item>
</style>
<!-- Style Title -->
<style name="Title">
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
<style name="AppTheme.OverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">@drawable/overflow_icon</item>
</style>
</resources>
फिलहाल मैं एंड्रॉइड स्टूडियो बीटा 0.8.9 का उपयोग करता हूं





Toolbarरेंडरिंग के लिए अपडेट हो सकते हैं ।