xml
1<?xml version="1.0" encoding="utf-8"?> 2<menu xmlns:android="http://schemas.android.com/apk/res/android"> 3 4 <item 5 android:id="@+id/navigation_home" 6 android:icon="@drawable/ic_home_black_24dp" 7 android:title="@string/title_home" /> 8 9 <item 10 android:id="@+id/navigation_dashboard" 11 android:icon="@drawable/ic_dashboard_black_24dp" 12 android:title="@string/title_dashboard" /> 13 14 <item 15 android:id="@+id/navigation_notifications" 16 android:icon="@drawable/ic_notifications_black_24dp" 17 android:title="@string/title_notifications" /> 18 19</menu> 20
xml
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.constraint.ConstraintLayout 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:id="@+id/container" 6 android:layout_width="match_parent" 7 android:layout_height="match_parent" 8 tools:context=".MainActivity"> 9 10 <TextView 11 android:id="@+id/message" 12 android:layout_width="wrap_content" 13 android:layout_height="wrap_content" 14 android:layout_marginLeft="@dimen/activity_horizontal_margin" 15 android:layout_marginStart="@dimen/activity_horizontal_margin" 16 android:layout_marginTop="@dimen/activity_vertical_margin" 17 android:text="@string/title_home" 18 app:layout_constraintLeft_toLeftOf="parent" 19 app:layout_constraintTop_toTopOf="parent" /> 20 21 <android.support.design.widget.BottomNavigationView 22 android:id="@+id/navigation" 23 android:layout_width="0dp" 24 android:layout_height="wrap_content" 25 android:layout_marginEnd="0dp" 26 android:layout_marginStart="0dp" 27 android:background="?android:attr/windowBackground" 28 app:layout_constraintBottom_toBottomOf="parent" 29 app:layout_constraintLeft_toLeftOf="parent" 30 app:layout_constraintRight_toRightOf="parent" 31 app:menu="@menu/navigation" /> 32 33</android.support.constraint.ConstraintLayout>
xml
1<resources> 2 3 <!-- Base application theme. --> 4 <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> 5 <!-- Customize your theme here. --> 6 <item name="colorPrimary">@color/colorPrimary</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 8 <item name="colorAccent">@color/colorAccent</item> 9 </style> 10 11</resources> 12
ビルドは通ります。テスト端末では初期ボタンは出力されています。アイコンを別のものにしたらしっかり別のもので出力されました。
ただ、なんのアイコンになったかテスト端末を通さないとわからない状態なので不便です。android studioの場合アイコンをxmlで定義したら左側にアイコンが表示されるかと思いますがアイコンを別のものにすると表示されなくなります。
main_activityのDesignでエラーになっている。右上にエラープロバイダが表示されている。状態です。
android studio 3.1.3
gradle
1apply plugin: 'com.android.application' 2 3android { 4 compileSdkVersion 28 5 defaultConfig { 6 applicationId "com.example.naoya.aniversarymanegement" 7 minSdkVersion 15 8 targetSdkVersion 28 9 versionCode 1 10 versionName "1.0" 11 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 } 13 buildTypes { 14 release { 15 minifyEnabled false 16 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 } 18 } 19} 20 21dependencies { 22 implementation fileTree(dir: 'libs', include: ['*.jar']) 23 implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' 24 implementation 'com.android.support:design:28.0.0-alpha3' 25 implementation 'com.android.support.constraint:constraint-layout:1.1.2' 26 implementation 'com.android.support:support-vector-drawable:28.0.0-alpha3' 27 testImplementation 'junit:junit:4.12' 28 androidTestImplementation 'com.android.support.test:runner:1.0.2' 29 androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 30} 31
回答1件
あなたの回答
tips
プレビュー