自分でオリジナルのアプリを作る際の基本!新しい画面の作り方を体験してみましょう。
このやり方を覚えると、好きなだけ画面を作ってアプリを拡張していくことができるようになります!
<activity android:name=".TameshiActivity" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar"> </activity>TameshiActivity のactivityノードに追加した属性については、以下の通りです。
Device Screen FrameLayout ImageView LinearLayout ImageView LinearLayout LinearLayout top_btn_map LinearLayout top_btn_howto top_btn_about
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/top_bg" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.4" android:scaleType="fitCenter" android:src="@drawable/top_image" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.6" android:gravity="center_horizontal" android:orientation="vertical"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"> <Button android:id="@+id/top_btn_map" android:layout_width="140dp" android:layout_height="80dp" android:layout_margin="5dp" android:background="@drawable/button_top_normal_wide" android:onClick="onClick" android:text="@string/top_btn_map" android:textColor="#fff" android:textSize="18sp" /> <Button android:layout_width="140dp" android:layout_height="80dp" android:text="ためし" android:id="@+id/top_btn_tameshi" android:layout_margin="5dp" android:textSize="18sp" android:background="@drawable/button_top_normal_wide" android:onClick="onClick" android:textColor="#fff" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/top_btn_howto" android:layout_width="140dp" android:layout_height="80dp" android:layout_margin="5dp" android:background="@drawable/button_top_normal" android:onClick="onClick" android:text="@string/top_btn_howto" android:textColor="#fff" android:textSize="18sp" /> <Button android:id="@+id/top_btn_about" android:layout_width="140dp" android:layout_height="80dp" android:layout_margin="5dp" android:background="@drawable/button_top_normal" android:onClick="onClick" android:text="@string/top_btn_about" android:textColor="#fff" android:textSize="18sp" /> </LinearLayout> </LinearLayout> </LinearLayout> </FrameLayout>
else if (v.getId() == R.id.top_btn_tameshi) { // ためし画面に遷移する Intent intent = new Intent(getApplicationContext(), TameshiActivity.class); startActivity(intent); }