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

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

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

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

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

Q&A

0回答

6735閲覧

Android StudioでUIのプレビューが表示されない

koue

総合スコア6

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

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

0グッド

0クリップ

投稿2018/03/02 04:59

編集2018/03/05 03:17

前提・実現したいこと

Android StudioでUIのプレビューが表示させたい

発生している問題

Android Studio 3.0.1でAndroidのUIをD&Dで作成したいのですが、content_model.xmlの画面でAndroidのUI画面が表示されません。

xmlにはラジオボタン3つ、ボタンを2つ表示するように書いているのですが、プレビュー(?)画面に表示されません。
イメージ説明

プレビュー画面を表示させるには何か設定が必要なのでしょうか?
解決策がありましたら教えて頂きたいです。

3年ほど前にAndroid Studioを使っていたときにはプレビュー画面で自由にボタン等の配置が出来ていたと思います。

java.lang.ClassNotFoundException: android.support.v4.view.OnApplyWindowInsetsListener
このエラーで表示がされていないような気がするのですが、どのように解決するのかが分かりません。

補足情報(FW/ツールのバージョンなど)

Android Studio 3.0.1
Windows7
開発対象のOS:Android 5.0.1

追記

コメントありがとうございます。
こちらは
プロジェクトを選択して右クリック「New」→「Activity」→「Basic Activity」→ActivityNameを入力→Finishをクリック
で作成すると、このような状態になります。(SelectModelActivity2を作成して状況を再現しました)
ラジオボタン、ボタンをRelativeLayoutで囲っても一枚目キャプチャの状態のままです。
xml、build.gradleの中身を書きましたので、こちらから分かることがありましたら教えて頂きたいです。

activity_select_model2.xml
activity_select_model2.xml
activity_select_model2.xmlの中身

activity_select_model2.xml

1<?xml version="1.0" encoding="utf-8"?> 2<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.example.xxxxxx.xxxx.SelectModelActivity2"> 8 9 <android.support.design.widget.AppBarLayout 10 android:layout_width="match_parent" 11 android:layout_height="wrap_content" 12 android:theme="@style/AppTheme.AppBarOverlay"> 13 14 <android.support.v7.widget.Toolbar 15 android:id="@+id/toolbar" 16 android:layout_width="match_parent" 17 android:layout_height="?attr/actionBarSize" 18 android:background="?attr/colorPrimary" 19 app:popupTheme="@style/AppTheme.PopupOverlay" /> 20 21 </android.support.design.widget.AppBarLayout> 22 23 <include layout="@layout/content_select_model2" /> 24 25 <android.support.design.widget.FloatingActionButton 26 android:id="@+id/fab" 27 android:layout_width="wrap_content" 28 android:layout_height="wrap_content" 29 android:layout_gravity="bottom|end" 30 android:layout_margin="@dimen/fab_margin" 31 app:srcCompat="@android:drawable/ic_dialog_email" /> 32 33</android.support.design.widget.CoordinatorLayout> 34

content_select_model2.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:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.xxxxxx.xxxx.SelectModelActivity2" tools:showIn="@layout/activity_select_model2"> <RadioGroup android:layout_margin="@dimen/activity_horizontal_margin" android:id="@+id/radioGroup" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioButton android:id="@+id/radioButton1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/radio_button_1" android:textSize="18sp"/> <RadioButton android:id="@+id/radioButton2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/radio_button_2" android:textSize="18sp"/> <RadioButton android:id="@+id/radioButton3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/radio_button_3" android:textSize="18sp"/> </RadioGroup> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/clea" android:id="@+id/button" android:textSize="18sp" android:layout_centerVertical="true" android:layout_alignLeft="@+id/radioGroup" android:layout_alignStart="@+id/radioGroup" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/submi" android:id="@+id/button2" android:textSize="18sp" android:layout_centerVertical="true" android:layout_centerHorizontal="true" /> </android.support.constraint.ConstraintLayout>

build.gradle (Module:app)の中身

gradle

1apply plugin: 'com.android.application' 2 3android { 4 compileSdkVersion 23 5 buildToolsVersion '25.0.0' 6 7 defaultConfig { 8 applicationId "com.example.xxxxxx.xxxx" 9 minSdkVersion 18 10 targetSdkVersion 23 11 versionCode 1 12 versionName "1.0" 13 multiDexEnabled true 14 } 15 buildTypes { 16 release { 17 minifyEnabled false 18 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 } 20 } 21} 22 23dependencies { 24 compile fileTree(include: ['*.jar'], dir: 'libs') 25 compile 'com.android.support:appcompat-v7:23.4.0' 26 compile 'com.google.android.gms:play-services:9.0.0' 27 compile 'com.android.support:design:23.4.0' 28 compile 'com.android.support:multidex:1.0.0' 29 compile 'com.android.support.constraint:constraint-layout:1.0.2' 30 testCompile 'junit:junit:4.12' 31}

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

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

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

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

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

keicha_hrs

2018/03/04 14:56 編集

プレビューにはCoordinatorLayoutと表示されていて、このレイアウトを描画できない問題のように見えるのですが、Component TreeにはCoordinatorLayoutなど存在しませんね。一体どうすればこういう状態になるのか不思議です。問題解決にはこのレイアウトのXMLファイルの内容と、対象モジュールのbuild.gradleの内容もご提示いただくことが必要と思いますが、現象が不可解だけにそれで私に回答できるかどうかはわかりません。
koue

2018/03/05 03:18

コメントをして頂きありがとうございます。追記に追加情報を記載しました。確認して頂けると幸いです。
keicha_hrs

2018/03/06 23:23 編集

ああ、includeされたレイアウトXMLファイルの内容でしたね。それくらい察するべきでした。ただ、これはかなり古いAndroid Studioで作られたプロジェクトですよね?古いプロジェクトを現在のASで開けるようにするのは、なかなか難しいかも。
koue

2018/03/08 09:54

このプロジェクトを作成したのは約二年前のAndroid Studioだと思います。古いプロジェクトを今のAndroid Studioで開くのが難しいというのは初耳でした。回答して頂きありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問