Android在布局中添加id会破坏我的代码

时间:2013-10-19 19:39:42

标签: android xml

有时当我在xml中为布局添加id时,它只会破坏我的代码。一切正常,直到我向布局添加id。没有错误,没有日志,它只是破坏了一切而没有注册任何错误。当我删除id时,一切都回来了。 (这不是“@ id / my_id” - >“@ + id / my_id”错误)

我想知道是什么原因造成的?

我遇到此问题的xml文件之一:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:orientation="vertical"
    tools:context=".MainActivity" >


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

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


               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/apparence" />  



       <LinearLayout 
                android:id="@+id/layout_apparence"  //HERE IS THE PROBLEM
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="6dp"
                android:layout_marginRight="6dp"
                android:layout_marginLeft="6dp"
                android:paddingRight="6dp"
                android:paddingTop="6dp"
                android:paddingLeft="6dp"
                android:paddingBottom="6dp"
                android:background="@drawable/note_corps" >

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/text_size_settings" />  

               <TextView 
                   android:id="@+id/fontSizePreview"
                   android:visibility="gone"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/font_size_is" />  

              <SeekBar
                  android:id="@+id/fontBar"
                  android:max="100"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" />



               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/card_size" />     

              <RadioGroup 
                  android:id="@+id/cardSize"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">

                  <RadioButton 
                      android:id="@+id/cardSizeSmall"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/card_size_small"/>

                  <RadioButton 
                      android:id="@+id/cardSizeNormal"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/card_size_normal"/>

                  <RadioButton 
                      android:id="@+id/cardSizeBig"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/card_size_big"/>

              </RadioGroup>



               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/theme" />     


              <RadioGroup 
                  android:id="@+id/themeChooser"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">

                  <RadioButton 
                      android:id="@+id/lightTheme"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/light_theme"/>

                  <RadioButton 
                      android:id="@+id/darkTheme"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/dark_theme"/>

              </RadioGroup>




         </LinearLayout>



              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/sort" />  




         <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical"
               android:layout_marginTop="6dp"
               android:layout_marginLeft="6dp"
               android:layout_marginRight="6dp"
               android:paddingRight="6dp"
               android:paddingTop="6dp"
               android:paddingLeft="6dp"
               android:paddingBottom="6dp"
               android:background="@drawable/note_corps"  >

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/order" />   



               <RadioGroup
                   android:id="@+id/sortNoteRadioGroup"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content">


                   <RadioButton
                       android:id="@+id/plusRecente"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:textColor="#666666"
                       android:text="@string/order_plus_recente" />

                   <RadioButton
                       android:id="@+id/plusAncienne"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:textColor="#666666"
                       android:text="@string/order_moins_recente" />

                   <RadioButton
                       android:id="@+id/alphaCroiss"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:textColor="#666666"
                       android:text="@string/order_alpha_croiss" />

                   <RadioButton
                       android:id="@+id/alphaDecroiss"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:textColor="#666666"
                       android:text="@string/order_alpha_decroi" />


               </RadioGroup>



         </LinearLayout>



              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/date_heure" /> 





           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical"
               android:layout_marginTop="6dp"
               android:layout_marginLeft="6dp"
               android:layout_marginRight="6dp"
               android:layout_marginBottom="6dp"
               android:paddingRight="6dp"
               android:paddingTop="6dp"
               android:paddingLeft="6dp"
               android:paddingBottom="6dp"
               android:background="@drawable/note_corps"  >

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/date_heure" />  

             <RadioGroup
                 android:id="@+id/precisionDate"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content">

                 <RadioButton
                      android:id="@+id/display_date_time"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/show_date_time" />

                  <RadioButton
                      android:id="@+id/hide_date_time"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/hide_date_time"/>

                 <RadioButton
                      android:id="@+id/hide_time"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/hide_time" />

             </RadioGroup>

       </LinearLayout>


              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/others" /> 


           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical"
               android:layout_marginTop="6dp"
               android:layout_marginLeft="6dp"
               android:layout_marginRight="6dp"
               android:layout_marginBottom="6dp"
               android:paddingRight="6dp"
               android:paddingTop="6dp"
               android:paddingLeft="6dp"
               android:paddingBottom="6dp"
               android:background="@drawable/note_corps"  >



              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/no_title" />   


              <RadioGroup 
                  android:id="@+id/noTitle"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">


                 <RadioButton 
                      android:id="@+id/leaveEmpty"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/leave_empty"/>

                  <RadioButton 
                      android:id="@+id/useDate"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/use_date"/>

                  <RadioButton 
                      android:id="@+id/useNote"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:textColor="#666666"
                      android:text="@string/use_note"/>

              </RadioGroup>

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/animations" />  

               <CheckBox 
                   android:id="@+id/disableAnimation"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:text="@string/disable_animation"/>


               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/suppression" />  

               <CheckBox 
                   android:id="@+id/disableConfirmation"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:text="@string/disable_confirmation"/>


         </LinearLayout>




                <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/editor_tips" /> 




           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical"
               android:layout_marginTop="6dp"
               android:layout_marginLeft="6dp"
               android:layout_marginRight="6dp"
               android:layout_marginBottom="6dp"
               android:paddingRight="6dp"
               android:paddingTop="6dp"
               android:paddingLeft="6dp"
               android:paddingBottom="6dp"
               android:background="@drawable/note_corps"  >



              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/editor_tips" /> 


              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#666666"
                   android:text="@string/tips" /> 



           </LinearLayout>



              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="14dp"
                   android:textColor="#C8C8C8"
                   android:textSize="20sp"
                   android:text="@string/about" />  





         <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical"
               android:layout_marginTop="6dp"
               android:layout_marginLeft="6dp"
               android:layout_marginRight="6dp"
               android:layout_marginBottom="6dp"
               android:paddingRight="6dp"
               android:paddingTop="6dp"
               android:paddingLeft="6dp"
               android:paddingBottom="6dp"
               android:background="@drawable/note_corps"  >

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/version" />      

              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#9A9A9A"
                   android:textSize="16sp"
                   android:text="@string/text_version" /> 

               <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#666666"
                   android:textSize="20sp"
                   android:text="@string/contact" />      

              <TextView 
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:layout_gravity="top|left"
                   android:layout_marginTop="6dp"
                   android:layout_marginLeft="6dp"
                   android:textColor="#9A9A9A"
                   android:textSize="16sp"
                   android:text="@string/report_to" /> 


         </LinearLayout>




    </LinearLayout>

    </ScrollView>


</LinearLayout>

1 个答案:

答案 0 :(得分:0)

好的,我没有找到原因,但是在运行Eclipse之前在设备上手动卸载应用程序清除了错误......