こんにちは!
最近メンバーに持ち上げてもらって調子に乗りそうな草もちです🤣
読者のみなさまの想像を壊さぬよう、一生顔出しはしないと心に誓いました🎅✨
さてさて、
AndroidStudioのレイアウトの続きを書いていきたいと思います。
前回はRelativeLayoutについて説明しました。
今回は
- Linerlayout
- Framelayout
について説明していきます!👨🍳
Linerlayout
Linerlayoutとは、並べることを目的としたレイアウトです。
android:orientation=“horizontal”を追加すると、
<LinearLayout 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" android:orientation="horizontal" tools:context=".MainActivity">
水平にTextViewが並びました。
android:orientation=“vertical”を追加すると、
<LinearLayout 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" android:orientation="vertical" tools:context=".MainActivity">
垂直方向に並びます。
Framelayout
Framelayoutはウィジェットを重ねて配置するためのレイアウトです。
書いた順に重ねられるので、一番最初に書いたものが一番下に配置されます。
具体例がこちら↓↓↓
<FrameLayout 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" android:orientation="vertical" tools:context=".MainActivity"> <ImageView android:id="@+id/imageView" android:layout_width="300dp" android:layout_height="300dp" app:srcCompat="@drawable/broccoli" /> <ImageView android:id="@+id/imageView2" android:layout_width="200dp" android:layout_height="200dp" app:srcCompat="@drawable/strawberry" /> <ImageView android:id="@+id/imageView3" android:layout_width="100dp" android:layout_height="100dp" app:srcCompat="@drawable/banana" /> </FrameLayout>
ちなみに画像の置く場所は、
画質荒くてすみません😥
app/res/drawable配下にコピペすればDesign画面のImageViewで使えます!
以上、AndroidStudioのレイアウトについてでした🎈✨

Androidアプリ開発のLinearLayoutの使い方【初心者向け】 | TechAcademyマガジン
Androidアプリ開発におけるレイアウトのうち【LinearLayout】の使い方について初心者向けに解説した記事。パーツを縦一列もしくは横一列に並べる場合に使用するレイアウトです。2種類あるので、どちらも紹介します。

アプリケーションのレイアウト - Qiita
レイアウトとは レイアウトとは、GUIの配置を決めるための仕組みです。 このレイアウトを使うことによって、Androidアプリの画面を簡単に作成することができます。 Android開発においては.xmlで記述してGUIを配置して...

Androidのレイアウト👶初心者向けざっくり理解 - Qiita
この投稿は、Androidアプリ開発を学び始めたばかりの初心者向けに、ざっくりとレイアウトについて説明をするために記述しました。 レイアウトの中からRelativeLayout/LinearLayoutの基本についてピックアップしてい...

[Android] ImageView 画像を表示させる3つの方法
アプリで画像を表示させるにはImageViewを使います。画像表示には色々方法がありますが、下のような3つの設定方法について試してみたいと思います。尚、こちらはJavaで KotlinでのImageViewはこちら