Xml文件  |  196行  |  8.34 KB

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- FYI: This layout has an extra top level container view that was previously used
     to allow for the insertion of debug info. The debug info is now gone, but the
     container remains because there is a high likelihood of UI regression relating
     to focus and selection states, some of which are specific to keyboard
     when touch mode is not enable. So, if you, heroic engineer of the future,
     decide to rip these out, please be sure to check out focus and keyboards. -->
<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:layout_margin="2dp"
    android:focusable="true">

    <com.google.android.material.card.MaterialCardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="2dp"
        android:elevation="0dp"
        android:duplicateParentState="true"
        app:cardElevation="0dp"
        app:strokeWidth="1dp"
        app:strokeColor="?android:strokeColor">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:duplicateParentState="true">

            <!-- Main item thumbnail.  Comprised of two overlapping images, the
                 visibility of which is controlled by code in
                 DirectoryFragment.java. -->

            <FrameLayout
                android:id="@+id/thumbnail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <com.android.documentsui.GridItemThumbnail
                    android:id="@+id/icon_thumb"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:scaleType="centerCrop"
                    android:contentDescription="@null"
                    android:tint="?attr/gridItemTint"
                    android:tintMode="src_over"/>

                <com.android.documentsui.GridItemThumbnail
                    android:id="@+id/icon_mime_lg"
                    android:layout_width="@dimen/icon_size"
                    android:layout_height="@dimen/icon_size"
                    android:layout_gravity="center"
                    android:scaleType="fitCenter"
                    android:contentDescription="@null"/>

            </FrameLayout>

            <FrameLayout
                android:id="@+id/preview_icon"
                android:layout_width="@dimen/button_touch_size"
                android:layout_height="@dimen/button_touch_size"
                android:layout_alignParentTop="true"
                android:layout_alignParentEnd="true"
                android:pointerIcon="hand"
                android:focusable="true"
                android:clickable="true">

                <ImageView
                    android:layout_width="@dimen/zoom_icon_size"
                    android:layout_height="@dimen/zoom_icon_size"
                    android:padding="2dp"
                    android:layout_gravity="center"
                    android:background="@drawable/circle_button_background"
                    android:scaleType="fitCenter"
                    android:src="@drawable/ic_zoom_out"/>

            </FrameLayout>

            <!-- Item nameplate.  Has a mime-type icon and some text fields (title,
                 size, mod-time, etc). -->

            <LinearLayout
                android:id="@+id/nameplate"
                android:background="?android:attr/colorBackground"
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/thumbnail">

                <FrameLayout
                    android:id="@+id/icon"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_centerVertical="true"
                    android:pointerIcon="hand"
                    android:paddingTop="8dp"
                    android:paddingBottom="8dp"
                    android:paddingStart="12dp"
                    android:paddingEnd="8dp">

                    <ImageView
                        android:id="@+id/icon_mime_sm"
                        android:layout_width="@dimen/grid_item_icon_size"
                        android:layout_height="@dimen/grid_item_icon_size"
                        android:layout_gravity="center"
                        android:scaleType="center"
                        android:contentDescription="@null"/>

                    <ImageView
                        android:id="@+id/icon_check"
                        android:src="@drawable/ic_check_circle"
                        android:alpha="0"
                        android:layout_width="@dimen/check_icon_size"
                        android:layout_height="@dimen/check_icon_size"
                        android:layout_gravity="center"
                        android:scaleType="fitCenter"
                        android:contentDescription="@null"/>

                </FrameLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="8dp"
                    android:paddingTop="8dp"
                    android:paddingEnd="12dp">

                    <TextView
                        android:id="@android:id/title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:layout_alignParentStart="true"
                        android:singleLine="true"
                        android:ellipsize="end"
                        android:textAlignment="viewStart"
                        android:textAppearance="@style/CardPrimaryText"/>

                    <TextView
                        android:id="@+id/details"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@android:id/title"
                        android:layout_marginEnd="4dp"
                        android:singleLine="true"
                        android:ellipsize="end"
                        android:textAlignment="viewStart"
                        android:textAppearance="@android:style/TextAppearance.Material.Caption"/>

                    <TextView
                        android:id="@+id/date"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@android:id/title"
                        android:layout_toEndOf="@id/details"
                        android:singleLine="true"
                        android:ellipsize="end"
                        android:textAlignment="viewStart"
                        android:textAppearance="@android:style/TextAppearance.Material.Caption"/>

                </RelativeLayout>

            </LinearLayout>

        </RelativeLayout>

    </com.google.android.material.card.MaterialCardView>

    <!-- An overlay that draws the item border when it is focused. -->
    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="1dp"
        android:background="@drawable/item_doc_grid_border_rounded"
        android:contentDescription="@null"
        android:duplicateParentState="true"/>

</FrameLayout>