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

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

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

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Android

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

Xamarin

Xamarin(ザマリン)は、iPhoneなどのiOSやAndroidで動作し、C# 言語を用いてアプリを開発できるクロスプラットフォーム開発環境です。Xamarin Studioと C# 言語を用いて、 iOS と Android の両方の開発を行うことができます。

Q&A

解決済

1回答

1891閲覧

Xamarin.FormでWebからダウンロードした画像を表示したい

pon-kotu

総合スコア3

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Android

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

Xamarin

Xamarin(ザマリン)は、iPhoneなどのiOSやAndroidで動作し、C# 言語を用いてアプリを開発できるクロスプラットフォーム開発環境です。Xamarin Studioと C# 言語を用いて、 iOS と Android の両方の開発を行うことができます。

0グッド

0クリップ

投稿2021/04/07 10:43

タイトルの通り、Webサイトからダウンロードした画像をAndroid画面に表示する方法を探しています。

検索してもリソースファイルとしてあらかじめ用意した画像を表示するものばかりで、URLを指定して表示するものはXMLファイルにImage要素を記述する方法しかありませんでした。しかし私の環境ではImageViewは利用できるのですが、Image要素は利用できないようです。
イメージ説明

現在は以下のようにしています。

XML

1<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 android:orientation="vertical" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent"> 5 <LinearLayout 6 android:orientation="vertical" 7 android:minWidth="25px" 8 android:minHeight="25px" 9 android:layout_width="match_parent" 10 android:layout_height="match_parent" 11 android:id="@+id/linearLayout1"> 12 13 14 <TextView 15 android:text="Large Text" 16 android:textAppearance="?android:attr/textAppearanceLarge" 17 android:layout_width="match_parent" 18 android:layout_height="wrap_content" 19 android:minWidth="25px" 20 android:minHeight="25px" 21 android:id="@+id/textView1" /> 22 <Button 23 android:text="Button" 24 android:layout_width="match_parent" 25 android:layout_height="wrap_content" 26 android:id="@+id/button1" 27 /> 28 <ImageView 29 android:src="@android:drawable/ic_menu_add" 30 android:layout_width="match_parent" 31 android:layout_height="wrap_content" 32 android:id="@+id/imageView1" 33 android:contentDescription="description" /> 34 35<!-- 下のIMAGE要素はエラーになる --> 36 <Image 37 android:layout_width="match_parent" 38 android:layout_height="wrap_content" 39 android:Source="https://i2.wp.com/oxamarin.com/wp-content/uploads/2016/12/りんちゃん.jpg" 40 /> 41 42 </LinearLayout> 43 44</LinearLayout> 45

C#

1Android.Widget.ImageView pic; 2pic = FindViewById<ImageView>(Resource.Id.imageView1); 3 4var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); 5 6//ダウンロード 7WebClient client = new WebClient(); 8client.DownloadFileAsync(new Uri("画像URL"), path + "/pic.png"); 9 10//ダウンロードした画像を表示 11Android.Net.Uri andrUri = Android.Net.Uri.Parse(path + "/pic.png"); 12pic.SetImageURI(andrUri);//表示できない 13

環境
VisualStudio2019
Pixel 2 pie 9.0 Android9.0-API28 Emulator

どうすれば画面に画像を表示できるでしょうか?

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

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

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

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

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

guest

回答1

0

自己解決

すいません、バカみたいなんですけど、特に弄ってないのに動きました。
どうもフォルダパスを通すのに非常に時間がかかっていただけだったみたいです。

自己解決にさせてください。

投稿2021/04/07 11:27

pon-kotu

総合スコア3

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問