close

今天在 GIt 版本合併之後出了點問題
Circular dependencies cannot exist in RelativeLayout

 

這問題是我進到某一個 Fragment 才會出現
所以我想應該是 Fragment 本身出了問題
檢查了一下,發現我的佈局 xml 有些怪怪的地方
我們注意看下方對應的顏色

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    。。。>

    <info.hoang8f.android.segmented.SegmentedGroup
        android:id="@+id/movieInfo_RadioGroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toStartOf=
                "@+id/movieInfo_selectBranchStoreLayout"
        。。。>

        <RadioButton
            android:id="@+id/movieInfo_radioComingSoon"
            。。。 />

        <RadioButton
            android:id="@+id/movieInfo_radioShowing"
            。。。 />
    </info.hoang8f.android.segmented.SegmentedGroup>

    <RelativeLayout
        android:id="@+id/movieInfo_selectBranchStoreLayout"
        android:layout_width="96dp"
        android:layout_height="28dp"
        android:layout_toEndOf="@+id/movieInfo_RadioGroup"
        。。。>

        <TextView
            android:id="@+id/movieInfo_selectBranchStoreName"
           。。。/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            。。。/>
    </RelativeLayout>
</RelativeLayout>

沒錯,這兩個屬性單看是沒什麼問題
但其實是有互相引用依賴 (循環依賴) 的問題

 

在 Relativelayout 中
元件a:「我看 元件b 站哪,我站他後面就好」
元件b:「我看 元件a 站哪,我站他前面就好」
因此而產生了錯誤
所以只要依自己需求,去掉其中一個就可以正常運行了
















資料來源:


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 顏澤偉 的頭像
    顏澤偉

    Willy's Fish教學筆記』

    顏澤偉 發表在 痞客邦 留言(0) 人氣()