0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Android Studio: 画像を表示

Last updated at Posted at 2023-10-02

Ubuntu 23.04 にインストールした Android Studio Giraffe | 2022.3.1 で確認しました。

プロジェクトの作成

Empty Views Activity を選ぶ
image.png

画像の取り込み

Tools -> Resource Manager
image.png

画像の追加
'+' をクリック
image.png

Import Drawables
image.png

ファイルを選択
image.png

Next
image.png

Import
image.png

## 画像の配置
activity_main.xml を選ぶ
image.png

画像をドラッグ
image.png

この時の、activity_main.xml をコードで表示
image.png

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/fuji_a"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="259dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

実行: Run

image.png

インストーラーの作成: Build APK(s)

image.png

apk-debug.apk を実機に持って行ってテスト

Screenshot_20231002-095148.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?