前提・実現したいこと
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
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}
あなたの回答
tips
プレビュー