2013-01-22 2 views
1

희망은 간단합니다.Scrollview XML 레이아웃 문제

나는 scrollview를 사용하는 레이아웃을 가지고 있습니다. 이것은 이미지와 텍스트 뷰를 그 위에 놓고 그 아래에있는 내 edittext와 함께 scrollview를 가질 때까지 괜찮 았습니다.

순간에 나는 다음과 같은 오류가 받고 있어요 : 나는 행운과 (내가 그 오류가 너무 가리키는 생각) 스크롤 뷰 너비 속성을 변경하는 것을 시도했다

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> 

편집을 볼 수

enter image description here

답변

2

를 당신 만있는 ScrollView 한 아이의 레이아웃을 설정할 수 있습니다. 나는 당신이 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> 
+0

@Ahmed 답장을 보내 주셔서 감사합니다. 선형 레이아웃과 내 이미지 및 텍스트 뷰를 추가했지만 이제 선형 레이아웃 내의 모든 내용이 표시되지 않습니다. – user1352057

+0

방향을 세로로 설정 했습니까? 스크롤 기능이 작동합니까? – Ahmad

+0

@Ahmed 예 선형 레이아웃은 수직 방향입니다. 나는 그것이 지금 무엇처럼 보이는지 보여주는 그림을 추가했습니다. scrollview는 완전히 비어 있습니다. – user1352057