为什么可以';我不能在Android Studio中看到我的设计吗?
我是一个初学者,在网上搜索了很长一段时间后,我没有找到令人满意的永久解决方案 问题是我无法在Android Studio 3.0.1中看到我的设计 我的屏幕是这样的: My STYLE.XML代码为什么可以';我不能在Android Studio中看到我的设计吗?,android,xml,android-layout,user-interface,Android,Xml,Android Layout,User Interface,我是一个初学者,在网上搜索了很长一段时间后,我没有找到令人满意的永久解决方案 问题是我无法在Android Studio 3.0.1中看到我的设计 我的屏幕是这样的: My STYLE.XML代码 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="hk.ust.cse.comp107x.chatclient.Contacts"
tools:showIn="@layout/activity_contacts">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/friendListView"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
我的活动\u contact.xml(这可能是协调员布局?)
试试看,
Gradle文件上的更改
compileSdkVersion 27
buildToolsVersion "27.0.0"
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:design:27.0.0'
testImplementation 'junit:junit:4.12'
您可能会遇到此错误 您需要在设计库中使用Theme.AppCompat主题(或子代) 我找到了一种解决方法,要求您明确定义协调器布局的主题
<android.support.design.widget.CoordinatorLayout
android:theme="@style/AppTheme.NoActionBar"
...
...>
请确保您使用的主题是theme.AppCompat的子主题,因为我可以看到这篇文章已经很老了,但我认为如果其他人也有同样的问题,那就好了 只需转到style.xml文件(该文件位于“值”下),并使用exmaple的“Base”扩展主题: 改变
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.NoActionBar">
添加此行,所有项目{repositories{jcenter()maven{url”“}}}注释不用于扩展讨论;对话已经结束。我们不要一次提出多个问题,将所有版本号设置为相同,因此尝试将所有版本号更改为25.3.1。
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "hk.ust.cse.comp107x.chatclient"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4.1'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
// Set this dependency to build and run UI Automator tests
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
}
compileSdkVersion 27
buildToolsVersion "27.0.0"
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:design:27.0.0'
testImplementation 'junit:junit:4.12'
<android.support.design.widget.CoordinatorLayout
android:theme="@style/AppTheme.NoActionBar"
...
...>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.NoActionBar">