teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

7

wrap_content

2019/01/15 09:56

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -1,8 +1,8 @@
1
1
  レイアウトについて
2
2
  ```
3
3
  <TextView
4
- android:layout_width="match_parent"
4
+ android:layout_width="wrap_content"
5
- android:layout_height="match_parent"
5
+ android:layout_height="wrap_content"
6
6
  android:text="hogehoge" />
7
7
  <ImageView
8
8
  android:layout_width="640dp"
@@ -10,8 +10,8 @@
10
10
  android:id="@+id/image222"
11
11
  />
12
12
  <TextView
13
- android:layout_width="match_parent"
13
+ android:layout_width="wrap_content"
14
- android:layout_height="match_parent"
14
+ android:layout_height="wrap_content"
15
15
  android:text="hogehoge2" />
16
16
  ```
17
17
  hogehogeでImageViewを囲いました。

6

以下画像をpathで指定したときに画像が表示されません。

2019/01/15 09:56

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -16,6 +16,14 @@
16
16
  ```
17
17
  hogehogeでImageViewを囲いました。
18
18
 
19
+ 以下layout/drawable/test.pngを設置したところ表示されたので、layoutは問題ないと思いました。
20
+ ```
21
+ ImageView iv = (ImageView) findViewById(R.id.image222);
22
+ iv.setImageResource(R.drawable.test);
23
+ ```
24
+
25
+ 以下画像をpathで指定したときに画像が表示されません。
26
+
19
27
  #1パターン目
20
28
  https://stackoverflow.com/questions/15814638/how-to-set-an-image-to-imageview-using-filepath-in-android
21
29
  を参考に以下を記述しました。

5

paths

2019/01/15 08:04

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  ```
24
24
  ImageView iv = (ImageView)findViewById(R.id.image222);
25
- path = "/sdcard/test.png";
25
+ String path = "/sdcard/test.png";
26
26
  iv.setImageBitmap(BitmapFactory.decodeFile(path));
27
27
  ```
28
28
 
@@ -43,7 +43,7 @@
43
43
  も参考に以下を記述しました。
44
44
  ```
45
45
  ImageView iv = (ImageView)findViewById(R.id.image222);
46
- path = "/sdcard/test.png";
46
+ String path = "/sdcard/test.png";
47
47
  File imgFile = new File(path);
48
48
  Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
49
49
  iv.setImageBitmap(myBitmap);

4

image222

2019/01/15 08:00

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -1,15 +1,15 @@
1
1
  レイアウトについて
2
2
  ```
3
- <TextView
3
+ <TextView
4
4
  android:layout_width="match_parent"
5
5
  android:layout_height="match_parent"
6
6
  android:text="hogehoge" />
7
- <ImageView
7
+ <ImageView
8
8
  android:layout_width="640dp"
9
9
  android:layout_height="360dp"
10
- android:id="@+id/image1"
10
+ android:id="@+id/image222"
11
11
  />
12
- <TextView
12
+ <TextView
13
13
  android:layout_width="match_parent"
14
14
  android:layout_height="match_parent"
15
15
  android:text="hogehoge2" />
@@ -21,7 +21,7 @@
21
21
  を参考に以下を記述しました。
22
22
 
23
23
  ```
24
- ImageView iv = (ImageView)findViewById(R.id.image1);
24
+ ImageView iv = (ImageView)findViewById(R.id.image222);
25
25
  path = "/sdcard/test.png";
26
26
  iv.setImageBitmap(BitmapFactory.decodeFile(path));
27
27
  ```
@@ -42,7 +42,7 @@
42
42
  https://stackoverflow.com/questions/4181774/show-image-view-from-file-path
43
43
  も参考に以下を記述しました。
44
44
  ```
45
- ImageView iv = (ImageView)findViewById(R.id.image1);
45
+ ImageView iv = (ImageView)findViewById(R.id.image222);
46
46
  path = "/sdcard/test.png";
47
47
  File imgFile = new File(path);
48
48
  Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());

3

hogehogeに囲まれてる画像は出ませんでした。

2019/01/15 07:59

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -35,7 +35,7 @@
35
35
  ```
36
36
 
37
37
 
38
- 表示したところhogehogeはでましたが、囲まれてるimageは出ませんでした。
38
+ 表示したところhogehogeはでましたが、hogehogeに囲まれてる画像は出ませんでした。
39
39
  ![イメージ説明](defdae4615463ba6d9335272db8b6e5d.png)
40
40
 
41
41
  #2パターン目
@@ -48,4 +48,4 @@
48
48
  Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
49
49
  iv.setImageBitmap(myBitmap);
50
50
  ```
51
- が同様にhogehogeはでましたが、囲まれてるimageは出ませんでした。
51
+ が同様にhogehogeはでましたが、hogehogeに囲まれてる画像は出ませんでした。

2

`````````

2019/01/15 07:59

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -29,8 +29,10 @@
29
29
 
30
30
 
31
31
  adb shellで端末内に画像があることは確認しました。
32
+ ```
32
- ls -ltA test.png
33
+ $ ls -ltA /sdcard/test.png
33
- -rw-rw---- 1 root sdcard_rw 522549 2019-01-15 15:48 test.png
34
+ -rw-rw---- 1 root sdcard_rw 522549 2019-01-15 15:48 /sdcard/test.png
35
+ ```
34
36
 
35
37
 
36
38
  表示したところhogehogeはでましたが、囲まれてるimageは出ませんでした。

1

````

2019/01/15 07:35

投稿

kaji
kaji

スコア648

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,5 @@
1
1
  レイアウトについて
2
+ ```
2
3
  <TextView
3
4
  android:layout_width="match_parent"
4
5
  android:layout_height="match_parent"
@@ -12,7 +13,7 @@
12
13
  android:layout_width="match_parent"
13
14
  android:layout_height="match_parent"
14
15
  android:text="hogehoge2" />
15
-
16
+ ```
16
17
  hogehogeでImageViewを囲いました。
17
18
 
18
19
  #1パターン目