Androidレイアウト解析、図文並茂(未完、続き)
36090 ワード
LinearLayout:Java GUIのFlowLayout(フローレイアウト)に相当します.つまり、1つのコンポーネントの後ろに1つ、隣接して、1つのコンポーネントが1行をいっぱい占めて、次の行に寄りかかっています.
linearlayoutdemo.xml
効果:
AbsolutelyLayout:絶対レイアウトは、Java GUIの空のレイアウトに相当し、何もありません.コンポーネントの位置は座標で表示する必要があります.でもandroid 2.3以降は廃棄されており,このレイアウトは多様なスクリーンサイズに適応できず,限界が大きいが,独立開発者,シングルマシンにとっては用いても構わない.
absolutelayoutdemo.xml
効果:
FrameLayout:このレイアウトは積層されており、ゲーム類のアプリケーションでよく使われ、NPCの構築ビューなどに関連しています.
framelayoutdemo.xml
効果:
RelativeLayout:関係レイアウトは、その名の通り、関係によって、誰が誰の左側にいるのか、誰が誰の上にいるのか、誰が前にいるのか、誰がそれに対しているのかなどです.属性はここでは後述しないが,必要に応じてAPIを調べればよい.
relativelayoutdemo.xml
効果:
GridLayout:グリッドレイアウト、N x Nをカスタマイズし、画面の外周に広げることができ、一部のゲームアプリケーションの地図が携帯電話の画面より大きい場合、このレイアウトを使用することができ、1枚の画像が大きすぎて、複数の画像でつなぎ合わせることができ、FrameLayoutを内蔵してNPCを地図上に実現することができると推測している.
gridlayoutdemo.xml
効果:
linearlayoutdemo.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/L1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="#ffffb859"
android:gravity="center"
android:text="@string/ll"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/L21"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#ff3fb200" />
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#ff3436b2" />
<TextView
android:id="@+id/tv5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="#ff7a75b2" />
<LinearLayout
android:id="@+id/L27"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="6"
android:orientation="vertical">
<LinearLayout
android:id="@+id/L37"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#ff44ff16"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:id="@+id/L32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#ff382aff"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
効果:
AbsolutelyLayout:絶対レイアウトは、Java GUIの空のレイアウトに相当し、何もありません.コンポーネントの位置は座標で表示する必要があります.でもandroid 2.3以降は廃棄されており,このレイアウトは多様なスクリーンサイズに適応できず,限界が大きいが,独立開発者,シングルマシンにとっては用いても構わない.
absolutelayoutdemo.xml
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ffff">
<Button
android:id="@+id/er"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="50dp"
android:layout_y="50dp"
android:background="#ff00ff"
android:text="@string/al" />
</AbsoluteLayout>
効果:
FrameLayout:このレイアウトは積層されており、ゲーム類のアプリケーションでよく使われ、NPCの構築ビューなどに関連しています.
framelayoutdemo.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fl"
android:textColor="#ffff2f25"
android:textSize="40sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fl"
android:textColor="#ff7e66ff"
android:textSize="70sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fl"
android:textColor="#ff5eff4f"
android:textSize="50sp" />
</FrameLayout>
効果:
RelativeLayout:関係レイアウトは、その名の通り、関係によって、誰が誰の左側にいるのか、誰が誰の上にいるのか、誰が前にいるのか、誰がそれに対しているのかなどです.属性はここでは後述しないが,必要に応じてAPIを調べればよい.
relativelayoutdemo.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#009922"
android:text="@string/rl"
android:textSize="40sp" />
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/t1"
android:background="#ff8800"
android:text="@string/rl"
android:textSize="40sp" />
</RelativeLayout>
効果:
GridLayout:グリッドレイアウト、N x Nをカスタマイズし、画面の外周に広げることができ、一部のゲームアプリケーションの地図が携帯電話の画面より大きい場合、このレイアウトを使用することができ、1枚の画像が大きすぎて、複数の画像でつなぎ合わせることができ、FrameLayoutを内蔵してNPCを地図上に実現することができると推測している.
gridlayoutdemo.xml
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="6"
android:orientation="horizontal"
android:rowCount="10">
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
<Button android:background="#ffff5651" />
<Button android:background="#ff45ff61" />
<Button android:background="#ff5d59ff" />
<Button android:background="#fff9ff52" />
<Button android:background="#ff31fff0" />
</GridLayout>
効果: