Android UI: Which layout options are mutually exclusive?

After developing layouts in Android for a while, I still can't figure it out. Often the results are unpredictable.

I think part of this boils down to some layout options not working well together. That is, if you use one way to specify the layout, you should not use any other way.

It is noteworthy that for me, a change layout_widthfrom fill_parentto wrap_contentusually changes the world. Let me give you another specific example:

Part of my activity layout is LinearLayout:

    <LinearLayout android:id="@+id/ll2" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:orientation="horizontal">
        <LinearLayout android:id="@+id/ll2a" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1">
            <TextView android:id="@+id/l_cover" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="@string/book_item_l_cover">
            </TextView>
            <ImageButton android:id="@+id/i_cover"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:scaleType="centerInside" android:gravity="center"
                android:layout_weight="1" android:adjustViewBounds="true"
                android:src="@drawable/spinner_black_76" android:minWidth="400dip">
            </ImageButton>
        </LinearLayout>
        <LinearLayout android:id="@+id/ll2b" android:layout_width="fill_parent"
            android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1">
            <TextView android:id="@+id/l_back_cover" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="@string/book_item_l_back_cover">
            </TextView>
            <ImageButton android:id="@+id/i_back_cover"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:scaleType="centerInside" android:gravity="center"
                android:layout_weight="1" android:adjustViewBounds="true"
                android:src="@drawable/spinner_black_76">
            </ImageButton>
        </LinearLayout>
    </LinearLayout>

2 , layout_weight. ImageButtons - adjustViewBounds. .

, , , , , , ( ). android:minWidth="400dip", . , (400 - ), .

, , minWidth - . , , , , . : - - () , - ?. . -?

+3
1

, layout_weight, , minWidth .

, 0 1, minWidth , layout_weight . , minWidth .

, . layout_weight:

"" .

, . , " " minWidth .

+2

Source: https://habr.com/ru/post/1768508/


All Articles