質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

2回答

3297閲覧

Android StdioでBottom Navigation Activity を使おうとしたのですが、activity_main.xmlのdesignにnavigationが表示されない

yoyoyo777

総合スコア9

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2018/08/10 02:21

前提・実現したいこと

Android StdioでBottom Navigation Activity を使おうとしたのですが、activity_main.xmlのdesignにnavigationが表示されないのです。

発生している問題・エラーメッセージ

render problem
Failed to find style 'bottomNavigationStyle' in current theme Tip: Try to refresh the layout.

missing style
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.

failed to instantiate one or more classes
The following classes could not be instantiated:
- android.support.design.widget.BottomNavigationView (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: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).   at android.support.design.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:221)   at android.support.design.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:196)   at android.support.design.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:131)   at android.support.design.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:110)   at android.support.design.widget.BottomNavigationView.<init>(BottomNavigationView.java:138)   at android.support.design.widget.BottomNavigationView.<init>(BottomNavigationView.java:114)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)   at android.view.LayoutInflater.inflate(LayoutInflater.java:515)   at android.view.LayoutInflater.inflate(LayoutInflater.java:394) Copy stack to clipboard

該当のソースコード

xml

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<android.support.design.widget.BottomNavigationView android:id="@+id/navigation" android:layout_width="0dp" android:layout_height="wrap_content" android:background="?android:attr/windowBackground" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/webView" app:menu="@menu/navigation" /> <WebView android:id="@+id/webView" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginBottom="8dp" android:layout_marginEnd="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" app:layout_constraintBottom_toTopOf="@+id/navigation" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

試したこと

style.xmlは、Base.を追加し以下の様にしました。

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

API 28のSDK Platformがインストールされた状態で新規プロジェクト作成をすると、Support LibraryもAPI 28のものが用いられますが、これに何かしら問題があってレイアウトエディターのデザイン上にビューが正常に表示されないようです。API 27のSDK PlatoformとSupport Libraryにすることで、表示は直すことができます。

app/build.gradle(修正箇所のみ)

Gradle

1android { 2 compileSdkVersion 27 3 defaultConfig { 4 targetSdkVersion 27 5 } 6} 7 8dependencies { 9 implementation 'com.android.support:appcompat-v7:27.1.1' 10 implementation 'com.android.support:design:27.1.1' 11}

投稿2018/08/10 05:32

keicha_hrs

総合スコア6768

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.yusk0.websitenavigation"
minSdkVersion 16
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 'com.android.support:appcompat-v7:27.0.0-rc01'
implementation 'com.android.support:design:27.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-vector-drawable:27.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test🏃‍♂️1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

このように変えたのですが、映らないままです!
イメージ説明

投稿2018/08/11 08:03

learningDeep

総合スコア13

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

keicha_hrs

2018/08/11 08:45

27.0.0-rc01 ではなく 27.1.1 にしてください。
keicha_hrs

2018/08/11 08:48

ん?質問者が回答欄に補足してしまったのかと思ったけど、なんで違う方なの?
learningDeep

2018/08/11 11:11

ログイン間違えました。 でも、できました!! ありがとうございます!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問