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

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

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

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

Android

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

Android Studio

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

Q&A

0回答

1702閲覧

正方形4つを2×2で等間隔に並べたい

sena14

総合スコア109

XML

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

Android

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

Android Studio

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

0グッド

0クリップ

投稿2020/06/05 15:02

frame_answerという画像は縦横比が1対1の画像です。
このframe_answerが設定されているImageViewを2×2で四つ並べたいのですがうまくできず困っています。

条件として
ImageViewの画像について縦横比1:1で表示したい。
それぞれの画像の中央にできる十字型の余白が縦と横で均等にしたい。
Viewの大きさは値ではなく割合で決まるようにしたい。

現状のコードですと中央の十字の余白が画面割合によって縦と横で幅が変わってしまいます。
どの様にしたら縦の余白と横の余白を同じに出来ますか?

よろしくお願いします。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:ads="http://schemas.android.com/apk/res-auto" android:orientation="vertical" tools:context=".Activity"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <Space android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="0dp" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> <Space android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <ImageView android:adjustViewBounds="true" android:id="@+id/qiv1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/frame_answer" /> <ImageView android:adjustViewBounds="true" android:id="@+id/qiv2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/frame_answer" /> <Space android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="0dp" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> <Space android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <ImageView android:adjustViewBounds="true" android:id="@+id/qiv3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/frame_answer" /> <ImageView android:adjustViewBounds="true" android:id="@+id/qiv4" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="2" android:src="@drawable/frame_answer" /> <Space android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> <Space android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> </LinearLayout>

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問