1

これが単純なものであることを願っています。

スクロールビューを使用するレイアウトがあります。これは、画像とテキストビューをその上に配置し、その下に編集テキストを含むスクロールビューを配置するまでは問題ありませんでした。

現時点では、次のエラーが発生しています。

01-22 20:13:32.228: E/AndroidRuntime(275): FATAL EXCEPTION: main
01-22 20:13:32.228: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flybase2/com.example.flybase2.addAppointment}: java.lang.RuntimeException: Binary XML file line #26: You must supply a layout_width attribute.

スクロールビューの幅属性(エラーも指していると思います)を変更しようとしましたが、うまくいきませんでした。

これが私のXMLです。誰かが私が間違っていることを見ることができますか?:

<?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="match_parent" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="84dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgLink"
        android:layout_width="78dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/viewcon" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:gravity="center"
        android:text="Appointments"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="35sp" />
</LinearLayout>

\\ERROR: On width attribute
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Name:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/inputAppName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Type:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Spinner
    android:id="@+id/spinner1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Time:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TimePicker
    android:id="@+id/timePicker1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Time:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<DatePicker
    android:id="@+id/datePicker1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Comments:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/inputAppCom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Set Appointment Date Alarm:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<ToggleButton
    android:id="@+id/toggleButton1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="ToggleButton"
    android:textOff="Alarm Off"
    android:textOn="Alarm On" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Add Appointment"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
    android:id="@+id/btnAddAppointment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Add" />

</ScrollView>
</LinearLayout>

編集:

ここに画像の説明を入力してください

4

1 に答える 1

2

ScrollViewに設定できる子レイアウトは1つだけです。属性を設定しなかった理由がわかりませんandroid:layout_widthが、問題は、ScrollViewに複数の子ビューがあることです。

<?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="match_parent" 
android:orientation="vertical" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="84dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgLink"
        android:layout_width="78dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:src="@drawable/viewcon" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="75dp"
        android:gravity="center"
        android:text="Appointments"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="35sp" />
</LinearLayout>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >


<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Name:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/inputAppName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Type:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Spinner
    android:id="@+id/spinner1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Time:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TimePicker
    android:id="@+id/timePicker1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Appointment Time:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<DatePicker
    android:id="@+id/datePicker1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Comments:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/inputAppCom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Set Appointment Date Alarm:"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<ToggleButton
    android:id="@+id/toggleButton1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="ToggleButton"
    android:textOff="Alarm Off"
    android:textOn="Alarm On" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Add Appointment"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
    android:id="@+id/btnAddAppointment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Add" />

 </LinearLayout>
 </ScrollView>
 </LinearLayout>
于 2013-01-22T20:31:24.803 に答える