dpとはdensity-independent pixelsの略です。
リフェレンス:https://developer.android.com/guide/practices/screens_support.html
match_parent: 親要素の幅
wrap_content: 中身の幅
dp:任意の幅
android:layout_width="match_parent" android:layout_width="wrap_content" android:layout_width="160dp" android:layout_height="160dp"
余白
android:layout_margin
android:padding
android:gravity, layout_gravity
android:layout_marginBottom="80dp" android:layout_marginLeft="40dp" android:paddingTop="10dp" android:gravity="bottom" android:layout_gravity="right"
android:layout_weight
android:layout_weight="1"
使用例
<Button
android:layout_weight="1"
android:text="hello_world"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/button2" />
<Button
android:layout_weight="1"
android:text="hello_world"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/button2" />
<Button
android:layout_weight="1"
android:text="hello_world"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:id="@+id/button2" />
RelativeLayout
android:id="@+id/a" android:layout_centerInParent="true" android:id="@+id/b" android:text="b" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/a" android:layout_below="@+id/a"
FrameLayout
<ImageView
android:text="a"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#f8bbd0"
android:layout_centerInParent="true"
/>
<ImageView
android:text="a"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#448aff"
android:layout_centerInParent="true"
/>
<ImageView
android:text="a"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#c2185b"
android:layout_centerInParent="true"
[/xml]
table layout
[xml]
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="1"></Button>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="1"></Button>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1"></Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="1"></Button>
</TableRow>
