Android 佈局 優先顯示右側的控件

需求如題
在這裏插入圖片描述
代碼

<LinearLayout
        android:layout_width="480dp"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:background="#0ff"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:maxLines="1"
                android:layout_weight="1"
                android:text="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />

            <TextView
                android:background="#0f0"
                android:text="Button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

            <TextView
                android:background="#ff0"
                android:text="Button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>

        </LinearLayout>

    </LinearLayout>

注意必須使用LinearLayout,相對佈局無法實現該效果。(會出現權重失效)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章