2013-10-03 2 views
0

Когда я пытаюсь смотреть на мой графический макет в журнале ошибок появляется это сообщение:Проблемы с графической компоновки

activity_main.xml: Круговые зависимости не могут существовать в RelativeLayout.

Как я буду исправлять это, чтобы мой код работал правильно? Я изменил вокруг alignParentLeft и установил их в true. Я также перепутал с align_above и align_below, которые не помогли. Я не уверен, в чем моя проблема.

Вот мой код:

 <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context=".MainActivity" > 


     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_marginTop="57dp" 
      android:text="Number of cups" /> 

     <EditText 
      android:id="@+id/editText1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@+id/textView1" 
      android:layout_marginRight="23dp" 
      android:layout_toRightOf="@+id/textView1" 
      android:ems="10" 
      android:inputType="number" > 

      <requestFocus /> 
     </EditText> 

      <CheckBox 
      android:id="@+id/go" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/cream" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="20dp" 
      android:text="To Go" /> 



     <CheckBox 
      android:id="@+id/cream" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/sugar" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="15dp" 
      android:text="Leave room for cream" /> 

     <CheckBox 
      android:id="@+id/sugar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/drinks" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="22dp" 
      android:text="Leave room for sugar" /> 

     <RadioGroup 
      android:id="@+id/drinks" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/sugar" 
      android:layout_above="@+id/flavoring" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentBottom="true" > 

      <RadioButton 
       android:id="@+id/coffee" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Coffee($2.50)" /> 

      <RadioButton 
       android:id="@+id/cappuccino" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:checked="true" 
       android:text="Cappucino($4.50)" /> 

      <RadioButton 
       android:id="@+id/espresso" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Espresso($4.50)" /> 

      <RadioButton 
       android:id="@+id/latte" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Latte($4.50)" /> 

      <RadioButton 
       android:id="@+id/iced_latte" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Iced Latte($5.00)" /> 
     </RadioGroup> 



     <TextView 
      android:id="@+id/flavoring" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/chocolate" 
      android:layout_alignParentLeft="true" 
      android:layout_marginTop="57dp" 
      android:text="Flavoring" /> 

     <CheckBox 
      android:id="@+id/chocolate" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/cherry" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="22dp" 
      android:text="Chocolate" /> 

      <CheckBox 
      android:id="@+id/cherry" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/vanilla" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="22dp" 
      android:text="Cherry" /> 

      <CheckBox 
      android:id="@+id/vanilla" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/cherry" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="22dp" 
      android:text="Vanilla" /> 

    <ScrollView 
      android:id="@+id/ScrollView01" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_alignLeft="@+id/editText1" 
      android:layout_alignParentBottom="true" > 


     </ScrollView> 


    </RelativeLayout> 

ответ

0

Это ваши проблемы

<CheckBox 
     android:id="@+id/sugar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/drinks" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="22dp" 
     android:text="Leave room for sugar" /> 

    <RadioGroup 
     android:id="@+id/drinks" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/sugar" 
     android:layout_above="@+id/flavoring" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true" > 

Вы рассказывающие sugar быть выше drinks и drinks быть ниже sugar. Вы можете сделать только один из них или попасть в бесконечный круг. Поэтому удалите android:layout_below="@+id/sugar" от drinks RadioGroup.

Я еще не вижу, если у вас есть это где-нибудь еще, но если вы это сделаете, вам также понадобится исправить это. Вы не можете сообщить View над другим и сообщить, что View будет ниже того же View ... с левым и правым.

Edit нашел еще

<CheckBox 
     android:id="@+id/cherry" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/vanilla" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="22dp" 
     android:text="Cherry" /> 

     <CheckBox 
     android:id="@+id/vanilla" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/cherry" 
     android:layout_alignParentLeft="true" 
     android:layout_marginBottom="22dp" 
     android:text="Vanilla" /> 

У вас есть то же самое происходит здесь. Вам нужно будет удалить above или below из одного из них.

+0

Спасибо за быстроту. Я удалил это из своего кода, но сообщение об ошибке все еще существует. Могут ли быть проблемы с флажками? – user2844612

+0

См. Мое редактирование .... – codeMagic

+0

Спасибо, сэр. Это исправило мой код. Я остерегаюсь тех, которые они меня отбрасывают. – user2844612

Смежные вопросы