lov*_*esh 4 android android-appcompat material-design
这是我的资源的样子
res/values/styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)
就像它在这里说的那样
res/values-v21/styles.xml
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
</style>
Run Code Online (Sandbox Code Playgroud)
和AndroidManifest.xml有
<application android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)
在我的MainActivity.java中,我从ActionBarActivity继承
public class MainActivity extends ActionBarActivity {
....
...
}
Run Code Online (Sandbox Code Playgroud)
现在,当我在KitKat(API 19)上运行应用程序时,应用程序运行,我看到Dark Action栏和材料设计但是当我在Android L(API 21)上运行时,应用程序崩溃说java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
.我知道这是因为我继承了ActionBarActivity
但是如果我使用appcompat
主题values-v21/styles.xml
那么我将如何使用材料主题?
Theme.AppCompat
如果在Lollipop设备上运行,则继承自Material到Platform主题:res/values-v21/styles.xml
在这种情况下不是必需的.
归档时间: |
|
查看次数: |
6922 次 |
最近记录: |