Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b00d0c7f authored by Cassy Chun-Crogan's avatar Cassy Chun-Crogan
Browse files

[DocsUI M3] Centre items in grid layout

Previously items (columns) were not centred leading to any extra spacing
going to the righthand side.

Add an outer FrameLayout layer where width is match_parent which will
evenly distribute the space between items. Within the FrameLayout
centre the actual grid item with center_horizontal.

See bug for demo.

Bug: 404978773
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: I379a9a97c0e6c3b8656a9c730e862cdc903de370
parent f9ecf709
Loading
Loading
Loading
Loading
+151 −144
Original line number Diff line number Diff line
@@ -13,19 +13,24 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/item_root"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:defaultFocusHighlightEnabled="false"
    android:focusable="true">

    <RelativeLayout
        android:layout_width="@dimen/grid_width"
        android:layout_height="@dimen/grid_height"
        android:layout_margin="@dimen/grid_item_margin"
    android:clickable="true"
    android:defaultFocusHighlightEnabled="false"
    android:focusable="true"
        android:layout_gravity="center_horizontal"
        android:paddingEnd="@dimen/grid_item_padding_end"
        android:paddingStart="@dimen/grid_item_padding_start"
    android:paddingTop="@dimen/grid_item_padding_top">
        android:paddingTop="@dimen/grid_item_padding_top"
        android:duplicateParentState="true">

    <!-- Main item thumbnail.  Comprised of two overlapping images, the
             visibility of which is controlled by code in
@@ -173,3 +178,5 @@
        </LinearLayout>

    </RelativeLayout>

</FrameLayout>
 No newline at end of file