Android 未在 android studio 3.1.3 中加载布局预览
Android layout preview not loading in android studio 3.1.3
这里的问题是 android studio 的预览工具无法加载我的视图,我有的其他视图没问题。
activity_maps_view.xml
<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:id="@+id/relativeTop"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".View.MapsView">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/signin_logoBackground"
android:cropToPadding="true"
android:scaleType="centerInside"
app:srcCompat="@drawable/login_logo_3x" />
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/top_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/nav_selector"
app:itemTextColor="@drawable/nav_selector"
app:menu="@menu/top_menu">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
</ScrollView>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/activity_maps_view" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/nav_selector"
app:itemTextColor="@drawable/nav_selector"
app:menu="@menu/bottom_menu">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
build.grade
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "de.bho_dive.app.android"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
}
如您所见,预览工具不会显示任何内容,我已经尝试更改主题,更改 android 版本,重新启动 android studio,再次导入项目,然后似乎没有任何效果。
有什么想法吗?
您是否尝试过从文件菜单
使cache/restart无效
Android studio -> File -> invalidate cache/restart
这里的问题是 android studio 的预览工具无法加载我的视图,我有的其他视图没问题。
activity_maps_view.xml
<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:id="@+id/relativeTop"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".View.MapsView">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/signin_logoBackground"
android:cropToPadding="true"
android:scaleType="centerInside"
app:srcCompat="@drawable/login_logo_3x" />
</LinearLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/top_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/nav_selector"
app:itemTextColor="@drawable/nav_selector"
app:menu="@menu/top_menu">
</android.support.design.widget.BottomNavigationView>
</LinearLayout>
</ScrollView>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/activity_maps_view" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:itemBackground="@android:color/white"
app:itemIconTint="@drawable/nav_selector"
app:itemTextColor="@drawable/nav_selector"
app:menu="@menu/bottom_menu">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
build.grade
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "de.bho_dive.app.android"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
}
如您所见,预览工具不会显示任何内容,我已经尝试更改主题,更改 android 版本,重新启动 android studio,再次导入项目,然后似乎没有任何效果。 有什么想法吗?
Android studio -> File -> invalidate cache/restart