RelativeLayout

RelativeLayoutは、UIを相対的に配置するためのレイアウトクラス・・・。

RelativeLayout | Android Developers

簡単なテキストを左上、真ん中、右下に配置する・・・。

activity_main.xmlで、

RelativeLayoutのタグで囲むと、それ以下は相対配置になる・・・。

最初のTextView(文字列を表示する部品)は、text1に定義された文字列を左上に表示する・・・。
"android:text"は表示文字列を表すプロパティ、"@string"はstrings.xmlに定義されているということ、'/'の後の"text1"はtext1という名前(name)のタグに値が定義されているということ・・・。

layout_alignParentLeftをtrueにすると親の部品(RelativeLayout)から見て左寄りに、
layout_alignParentTopをtrueにすると親の部品(RelativeLayout)から見て上寄りに配置される・・・。
結果、左上に配置されるというわけ・・・。

text2はlayout_centerInParentをtrueにすることで中央に配置される・・・。

text3は、layout_alignParentRightとlayout_alignParentBottomがtrueなので右下に配置される・・・。

text1、text2、text3の文字列はstrings.xmlに定義されている・・・。

text1はABCDE、text2はFGHIJ、text3はKLMNO・・・。

f:id:BG1:20160219121520p:plain

左上、真ん中、右下に表示されている・・・。

Sample/MainActivity.java at master · bg1bgst333/Sample · GitHub
Sample/activity_main.xml at master · bg1bgst333/Sample · GitHub
Sample/strings.xml at master · bg1bgst333/Sample · GitHub
Sample/AndroidManifest.xml at master · bg1bgst333/Sample · GitHub