###前提・実現したいこと
Androidstudioでアプリ開発の勉強をしています。
そこで画像を表示させたいので、ImageViewを使いました。
しかし、エミュレータで実行させると画像が表示されません。
どうすれば画像が表示されるのでしょうか?
###発生している問題・エラーメッセージ
・画像がエミュレータで実行すると表示されない。
Designで編集する画面では表示されています。
エミュレータのデバイスはNexus6を使用しています。
###該当のソースコード
xml
1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout 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 android:weightSum="1" 8 android:orientation="vertical" 9 tools:context=".OmikujiActivity"> 10 11 <ImageView 12 android:id="@+id/imageView1" 13 android:layout_width="match_parent" 14 android:layout_height="wrap_content" 15 android:scaleType="fitCenter" 16 app:srcCompat="@drawable/omikuji" 17 android:layout_weight="0.96" /> 18 19 <Button 20 android:id="@+id/button" 21 android:layout_width="match_parent" 22 android:layout_height="58dp" 23 android:text="うらなう" /> 24 25</LinearLayout>
Java
1package jp.wings.nikkeibp.omikuji; 2 3import android.app.Activity; 4import android.os.Bundle; 5import android.widget.TextView; 6 7import java.util.Random; 8 9public class OmikujiActivity extends Activity 10{ 11 @Override 12 protected void onCreate(Bundle savedInstanceState) 13 { 14 super.onCreate(savedInstanceState); 15 setContentView(R.layout.omikuji); 16 17 } 18} 19
表示させたい画像:omikuji.png
xmlファイル:omikuji.xml
###試したこと
・再起動
・画像のサイズを小さくする。
###補足情報(言語/FW/ツール等のバージョンなど)
Androidstudio2.3
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/03/31 04:36