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

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

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

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

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

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

1279閲覧

android:backgroundに正方形の画像を設定しましたが、画像が伸びます

alizona

総合スコア126

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

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

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2020/08/06 11:50

android:background="@drawable/rectangle_green"
とRelativeLayoutに設定しているのですが、画像が縦に伸びてしまいます。
イメージ説明

android:background="@drawable/rectangle_green"
のコードを抜くと、こうなります。(緑の背景がなくなります。茶色の背景は、緑の下方のものです。
イメージ説明

使用している画像はこのように934 x 934 の正方形です。
イメージ説明

どうすれば改善できるでしょうか?

xml

1<?xml version="1.0" encoding="utf-8"?> 2 3<RelativeLayout 4 xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:tools="http://schemas.android.com/tools" 6 xmlns:app="http://schemas.android.com/apk/res-auto" 7 tools:context=".MainActivity" 8 android:layout_width="match_parent" 9 android:layout_height="match_parent"> 10 11 12 <ScrollView 13 android:layout_width="match_parent" 14 android:layout_height="match_parent" 15 android:background="#3900D4D4"> 16 17 18 <LinearLayout 19 android:layout_width="match_parent" 20 android:layout_height="wrap_content" 21 android:layout_margin="10dp" 22 android:orientation="vertical"> 23 24 <RelativeLayout 25 android:layout_width="match_parent" 26 android:layout_height="?actionBarSize"> 27 28 <TextView 29 android:layout_width="wrap_content" 30 android:layout_height="wrap_content" 31 android:layout_centerVertical="true" 32 android:fontFamily="@font/faster_one" 33 android:padding="10dp" 34 android:text="Race &amp; Win" 35 android:textAllCaps="true" 36 android:textColor="#7CFF9800" 37 android:textSize="30sp" /> 38 39 <Spinner 40 android:id="@+id/date_spinner" 41 android:layout_width="55dp" 42 android:layout_height="wrap_content" 43 android:padding="5dp" 44 android:layout_toStartOf="@+id/c_name_spinner" 45 android:entries="@array/date_list" 46 android:layout_centerVertical="true" 47 android:layout_marginEnd="5dp" 48 android:background="#4600D4D4" 49 android:backgroundTint="#FFFFFF" 50 android:textAlignment="center" 51 /> 52 53 <Spinner 54 android:id="@+id/c_name_spinner" 55 android:layout_width="55dp" 56 android:layout_height="wrap_content" 57 android:layout_toStartOf="@+id/num_race_spinner" 58 android:padding="5dp" 59 android:entries="@array/c_name_list" 60 android:layout_centerVertical="true" 61 android:layout_marginEnd="5dp" 62 android:background="#4600D4D4" 63 android:backgroundTint="#FFFFFF" 64 android:textAlignment="center" 65 /> 66 67 <Spinner 68 android:id="@+id/num_race_spinner" 69 android:layout_width="55dp" 70 android:layout_height="wrap_content" 71 android:padding="5dp" 72 android:entries="@array/num_race_list" 73 android:layout_centerVertical="true" 74 android:layout_alignParentEnd="true" 75 android:background="#4600D4D4" 76 android:backgroundTint="#FFFFFF" 77 android:layout_marginEnd="5dp" 78 android:textAlignment="center" 79 /> 80 </RelativeLayout> 81 82 <RelativeLayout 83 android:layout_width="match_parent" 84 android:layout_height="match_parent"> 85 86 <!--950, 342--> 87 <RelativeLayout 88 android:id="@+id/size" 89 android:layout_width="match_parent" 90 android:layout_height="match_parent" 91 android:layout_margin="15dp" 92 android:background="@drawable/rectangle_green"> 93 94 <TextView 95 android:id="@+id/course" 96 android:layout_width="wrap_content" 97 android:layout_height="wrap_content" 98 android:layout_marginStart="7dp" 99 android:layout_marginTop="13dp" 100 android:layout_marginBottom="100dp" 101 android:fontFamily="@font/bonbon" 102 android:text="日本" 103 tools:ignore="InvalidId" /> 104 105 <TextView 106 android:layout_width="wrap_content" 107 android:layout_height="wrap_content" 108 android:background="#00000000" 109 android:fontFamily="@font/bonbon" 110 android:layout_marginStart="40dp" 111 android:layout_marginEnd="20dp" 112 android:layout_marginTop="30dp" 113 114 android:padding="5dp" 115 /> 116 117 </RelativeLayout> 118 119 <ImageView 120 android:layout_width="50dp" 121 android:layout_height="50dp" 122 android:src="@drawable/rectangle" 123 android:layout_alignParentStart="true" 124 android:layout_alignParentTop="true" 125 android:layout_marginStart="10dp" 126 android:layout_marginTop="10dp" 127 /> 128 129 130 131 <ImageView 132 android:layout_width="50dp" 133 android:layout_height="50dp" 134 android:src="@drawable/cource" 135 android:layout_marginTop="0dp" 136 android:layout_alignParentEnd="true" 137 android:layout_marginEnd="3dp"/> 138 </RelativeLayout> 139 140 141 142 143 </LinearLayout> 144 145 </ScrollView> 146 147 <com.google.android.material.floatingactionbutton.FloatingActionButton 148 android:id="@+id/fab" 149 android:layout_width="62dp" 150 android:layout_height="62dp" 151 android:layout_alignParentEnd="true" 152 android:layout_alignParentBottom="true" 153 android:layout_margin="@dimen/fab_margin" 154 android:src="@drawable/plus"/> 155 156</RelativeLayout> 157

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

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

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

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

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

guest

回答1

0

自己解決

画像が縦に伸びている理由は、画像の横幅が大きすぎるからでした。
300x300にしたら正方形になりました。
イメージ説明

投稿2020/08/06 12:32

alizona

総合スコア126

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問