对不起,也许这不是一个新的话题,但真的需要帮助,我尝试了很多关于这个的帖子,但我的问题仍然没有解决,我是关于android的新手。我尝试学习Material Design,我使用android lollipop, API level 22.
我尝试使用compile 'com.android.support:support-v4:22.0.0'
。同步gradle后,我仍然无法使用Theme.AppCompat.Light.NoActionBar
作为style.xml
文件上的主题。这是我完整的gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "afnan.project.com.materialdesign"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
com.android.support:support-v4:22.0.0'
}
是否有其他设置,以便我可以尝试使用这个主题,或者主要问题是什么?请告诉我,需要建议…
主题Theme.AppCompat.*
用于定义与旧android 2的兼容性。x版本。这需要support-v7
如果你需要与android 2.2或2.3兼容,请在gradle build中包含
compile 'com.android.support:support-v7:22.0.0'
或者如果你构建的是android-3.0或更高版本,将AppCompat
替换为Holo
。
- Theme.AppCompat.Light.NoActionBar
是
- Theme.Holo.Light.NoActionBar
在Android Studio中右键单击Gradle并右键单击鼠标按钮刷新Gradle项目问题解决
要使用AppCompat主题,您必须在您的项目中包含此库。
compile 'com.android.support:appcompat-v7:22.2.0'
我还建议你使用最新版本22.2.0而不是22.0.0
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
//You can remove this line, because the appcompat has the support-v4 as dependency
//com.android.support:support-v4:22.0.0'
}
之前是
<style name="LaunchTheme" parent="@android:style/Theme.AppCompat.Light.NoActionBar">
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">