gpt4 book ai didi

android - android中缺少样式

转载 作者:行者123 更新时间:2023-11-29 19:21:10 25 4
gpt4 key购买 nike

我正在使用 android studio 2.2.3。我所有的布局 xml 都在提示“缺少样式”。以下是我在打开设计 View 时遇到的错误。

呈现问题缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。无法在当前主题中找到样式“progressBarStyle”(未显示 1568 个类似错误)无法在当前主题中找到“?attr/textAppearanceSmall”。 (65个类似错误未显示)

我还注意到 styles.xml 找不到“Theme.AppCompat.Light.NoActionBar”。我已经检查了项目结构,并且能够在依赖项列表中看到 com.android.support.appcompat-v7:25.2.0。我执行了无效缓存并重新启动,清理/构建。但我无法摆脱缺少样式的问题。我还尝试将我的“AppTheme”重命名为“AppBaseTheme”并在我的 android list 文件中引用它。即使那样也无济于事。我已经尝试在设计 View 中进行刷新,但仍然无法摆脱缺少样式的错误。对于另一个 xml 布局,我收到以下错误

Rendering Problems Missing styles. Is the correct theme chosen for this layout? >Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. The following classes could not be instantiated: - android.support.design.widget.TabLayout (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.   at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:36)   at android.support.design.widget.TabLayout.(TabLayout.java:297)   at android.support.design.widget.TabLayout.(TabLayout.java:291)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

有人能给我指出正确的方向吗?谢谢。

以下是我的 list 。

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:name=".ExampleApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activity.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>
</application>

以下是我的build.gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.package"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}

dexOptions {
preDexLibraries true
javaMaxHeapSize "4g"
}

lintOptions {
abortOnError false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

testOptions {
unitTests.returnDefaultValues = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile group: 'joda-time', name: 'joda-time', version: '2.9.6'
compile group: 'com.google.guava', name: 'guava', version: '20.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.github.zagum:Android-SwitchIcon:1.3.2'
compile 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'
compile 'com.prolificinteractive:material-calendarview:1.4.2'

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

compile 'com.google.dagger:dagger:2.7'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'


testCompile 'junit:junit:4.12'
testCompile "org.robolectric:robolectric:3.0"
testCompile "org.robolectric:shadows-support-v4:3.0"
testCompile 'org.mockito:mockito-core:1.10.19'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
}

以下是我的 styles.xml。

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
<item name="android:editTextStyle">@style/RobotoEditTextStyle</item>
</style>

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>

<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textSize">@dimen/body</item>
<item name="android:textColor">@color/colorBlack</item>
</style>

<style name="RobotoEditTextStyle" parent="android:Widget.EditText">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textSize">@dimen/body</item>
<item name="android:padding">@dimen/edittext_padding</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>

<style name="TextInputLayoutStyle" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">@color/color_android_green</item>
<item name="android:textStyle">bold|italic</item>
</style>

<style name="TextInputLayoutStyleError" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">@color/colorRed</item>
<item name="android:textStyle">bold|italic</item>
</style>

<style name="CustomTextStyle" parent="@android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">20sp</item>
</style>

<style name="CustomSwitch" parent="Theme.AppCompat.Light">
<!-- active thumb & track color (30% transparency) -->
<item name="colorControlActivated">@color/colorAccent</item>

<!-- inactive thumb color -->
<item name="colorSwitchThumbNormal">@color/colorGrayDarker</item>

<!-- inactive track color (30% transparency) -->
<item name="android:colorForeground">@color/colorGray</item>
</style>

<style name="CustomTabLayout" parent="Base.Widget.Design.TabLayout">
<item name="tabIndicatorColor">@color/colorGold</item>
<item name="tabSelectedTextColor">@color/colorGold</item>
</style>

<style name="StyledScrollerTextAppearance">
<item name="android:textColor">@color/colorWhite</item>
</style>

Tablayout xml fragment

    <android.support.design.widget.TabLayout
android:id="@+id/callScheduleType"
style="@style/CustomTabLayout"
android:layout_width="0dp"
android:layout_height="40dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guidelineNavHeight">

<android.support.design.widget.TabItem
android:id="@+id/personal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="personal"/>

<android.support.design.widget.TabItem
android:id="@+id/community"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="community"/>
</android.support.design.widget.TabLayout>

最佳答案

我能够通过将 android gradle 插件版本从类路径 'com.android.tools.build:gradle:2.3.0-beta4' 恢复到类路径 'com.android.tools.build:gradle: 2.2.3' 在项目顶级构建文件中。

关于android - android中缺少样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42439810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com