futabooo blog

色々手をつけすぎてすぐに忘れるので備忘録

初めてのAndroidプログラミング備忘録(2)

何記事か書くようになってこのタグの付け方はありなのか?わかりづらくないか?
と思い始めてきたfutaboooですこんにちは!

今日も先日に引き続きLayoutとViewに格闘していました。
今日わかったことはlayout_widthの値に"wrap_content"を定義すると、EditTextクラスの時にどう動くのかってこと。

今日書いたのがエミュレータの表示だとこんな感じ。ここの一つ目のテキストボックスに入力したら。1個したの画像みたいになった。
f:id:futabooo:20120119174440p:image
f:id:futabooo:20120119174439p:image


コード全体はこれ。更に下の方に問題の部分だけ抜き出したもの。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

	<TextView
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_marginTop="5dp"
		android:layout_marginBottom="5dp"
		android:text="お申し込みフォーム"
		android:textAppearance="?android:attr/textAppearanceLarge"  />

	<LinearLayout
	    xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="horizontal">
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="お名前:"/>
			<EditText
			    android:id="@+id/namae"
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"/>
	</LinearLayout>

	<LinearLayout
		xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="horizontal">
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="住所:"/>
			<EditText
			    android:id="@+id/jyuusho"
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"/>
	</LinearLayout>

	<LinearLayout
	    xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="horizontal">
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="生年月日:"/>
			<Spinner
			    android:id="@+id/seinengappi_tuki"
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:entries="@array/tuki" />
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="月"/>
			<Spinner
			    android:id="@+id/seinengappi_nichi"
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:entries="@array/nichi" />
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="日"/>
	</LinearLayout>

	<LinearLayout
	    xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:orientation="horizontal">
			<TextView
			    android:layout_width="wrap_content"
			    android:layout_height="wrap_content"
			    android:text="性別:"/>
			<RadioGroup
				android:layout_width="match_parent"
				android:layout_height="wrap_content"
				android:orientation="vertical">
					<RadioButton
					    android:id="@+id/male"
					    android:layout_width="wrap_content"
					    android:layout_height="wrap_content"
					    android:text="男" />
					<RadioButton
					    android:id="@+id/female"
					    android:layout_width="wrap_content"
					    android:layout_height="wrap_content"
					    android:text="女" />
			</RadioGroup>
	</LinearLayout>
</LinearLayout>


問題の部分だけ抜き出すとこれ。

<EditText
    android:id="@+id/namae"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

"wrap_content"を任意の値にすればいいだね!

これってXMLファイルだからJAVAってタグじゃないんじゃないか?(´・ω・`)
ブログの文書の書き方が定まらない。。。