单击RecylcerView

时间:2016-02-10 09:45:12

标签: android android-recyclerview

我想使用Recyclerview创建一个包含项目的列表,我已经设法使这些项目可以选择。

我已经设法通过使用ActionMode实现来显示工具栏。这几乎是例外结果,但是我的抽象布局的操作栏顶部会出现一个新的操作栏,如下所示: enter image description here

如何在主工具栏前显示包含所选项目的工具栏? 我试图显示/隐藏我的活动工具栏,但这会导致闪烁,因为黑色操作栏淡出。

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorPrimary</item>
        <item name="android:fontFamily">sans-serif-light</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

    <style name="AppTheme.Drawer" parent="ThemeOverlay.AppCompat.Dark">
        <item name="android:popupMenuStyle">@style/PopupMenu</item>
    </style>

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>


    <!-- Voor LOGIN -->
    <style name="TextLabel" parent="AppTheme.Auth">
        <item name="colorPrimary">#C56FFF</item>
        <item name="colorPrimaryDark">#FF6F8B</item>
        <item name="colorAccent">#FFC46F</item>


        //hint color And Label Color in False State
        <item name="android:textColorHint">@android:color/white</item>
        <item name="android:textSize">20sp</item>
        //Label color in True State And Bar Color False And True State
        <item name="colorControlNormal">@android:color/white</item>
        <item name="colorControlActivated">@android:color/white</item>
        <item name="colorControlHighlight">#F9F0FF</item>

        <item name="android:textColor">#FFF</item>
        <item name="android:textColorHighlight">#FFF</item>
        <item name="android:textColorLink">#FFF</item>
    </style>

    <style name="GeneralText" parent="AppTheme.Auth">
        //hint color And Label Color in False State
        <item name="android:textColorHint">@color/secondary_text</item>
        <item name="android:textSize">16sp</item>
        <item name="android:fontFamily">sans-serif-light</item>
        //Label color in True State And Bar Color False And True State
        <item name="colorControlNormal">#D1D1D1</item>
        <item name="colorControlActivated">#D1D1D1</item>
        <item name="colorControlHighlight">#D1D1D1</item>

        <item name="android:textColor">@color/primary_text</item>
        <item name="android:textColorHighlight">@color/primary_text</item>
        <item name="android:textColorLink">@color/primary_text</item>
    </style>

    <style name="AppTheme.Auth" parent="AppTheme.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="android:textColorPrimary">@android:color/white</item>
    </style>

    <style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
        <item name="android:textColorPrimary">@android:color/black</item>
        <item name="android:colorBackground">@color/light_gray_bar</item>
    </style>

    <!--TODO: REMOVE Style voor TableRowSpacer -->
    <style name="LabelEditRowSpacer">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:minHeight">20dp</item>
        <item name="android:paddingLeft">8dp</item>
        <item name="android:paddingRight">8dp</item>
    </style>

    <!--Style voor TableRow -->
    <style name="LabelEditRow">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginTop">-1dp</item>
        <item name="android:background">@drawable/tableborder</item>
        <item name="android:paddingLeft">8dp</item>
        <item name="android:paddingRight">8dp</item>
        <item name="android:visibility">gone</item>
    </style>

    <!--Style voor TextInputLayout -->
    <style name="LabelEditLayout">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginBottom">8dp</item>
        <item name="android:layout_marginTop">8dp</item>
        <item name="android:layout_weight">3</item>
        <item name="android:theme">@style/GeneralText</item>
    </style>

    <!--Style voor EditText -->
    <style name="LabelEdit" parent="GeneralText">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:background">#ffffff</item>
        <item name="android:clickable">false</item>
        <item name="android:cursorVisible">false</item>
        <item name="android:focusable">false</item>
        <item name="android:focusableInTouchMode">false</item>
        <item name="android:inputType">textCapWords</item>
        <item name="android:padding">5dp</item>
    </style>

    <style name="LabelEditMulti" parent="LabelEdit">
        <item name="android:inputType">textMultiLine</item>
    </style>

    <style name="LabelCheckbox" parent="GeneralText">
        <item name="android:padding">5dp</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
    </style>

    <!--Style voor Spinner -->
    <style name="Spinner" parent="LabelEdit">
        <item name="android:padding">0dp</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
    </style>

    <!--Style voor Spinner -->
    <style name="SpinnerItem" parent="GeneralText">
        <item name="android:layout_marginTop">0dp</item>
        <item name="android:paddingTop">0dp</item>
    </style>

    <style name="weekDayText">
        <item name="android:textSize">16sp</item>
    </style>

    <style name="dateText">
        <item name="android:textSize">18sp</item>
    </style>

    <!-- FONTAWESOME FAB BUTTONS -->
    <!-- FabMenu labels -->
    <style name="MenuLabelsStyle">
        <item name="android:background">@drawable/fab_label_background</item>
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textSize">14sp</item>
        <item name="android:maxLines">2</item>
        <item name="android:ellipsize">end</item>
    </style>

    <style name="FabMenuAwesome">
        <item name="menu_colorNormal">@color/fab_parent</item>
        <item name="menu_colorPressed">@color/fab_parent_pressed</item>
        <item name="menu_colorRipple">@color/fab_parent_ripple</item>
        <item name="fab_shadowColor">#444</item>
        <item name="menu_animationDelayPerItem">0</item>
        <item name="menu_labels_style">@style/MenuLabelsStyle</item>
        <item name="menu_labels_showAnimation">@anim/jump_from_down</item>
        <item name="menu_labels_hideAnimation">@anim/jump_to_down</item>
        <item name="android:paddingBottom">7dp</item>
        <item name="android:paddingRight">7dp</item>
    </style>

    <!--FabAwesome als enkele dbutton -->
    <style name="ParentFabAwesome">
        <item name="fab_colorNormal">@color/fab_parent</item>
        <item name="fab_colorPressed">@color/fab_parent_pressed</item>
        <item name="fab_colorRipple">@color/fab_parent_ripple</item>
        <item name="fab_shadowColor">#444</item>
        <item name="android:layout_marginBottom">7dp</item>
        <item name="android:layout_marginRight">7dp</item>
    </style>

    <!--FabAwesome als child dbutton -->
    <style name="FabAwesome">
        <item name="fab_size">mini</item>
        <item name="fab_showAnimation">@anim/jump_from_down</item>
        <item name="fab_hideAnimation">@anim/jump_to_down</item>
        <item name="fab_shadowColor">#444</item>
        <item name="fab_colorNormal">@color/fab_option</item>
        <item name="fab_colorPressed">@color/fab_option_pressed</item>
        <item name="fab_colorRipple">@color/fab_option_ripple</item>
        <item name="android:visibility">gone</item>
    </style>

    <!-- LABEL SEARCH, wordt nu niet gebruikt, maar laten staan voor toekomstige wijzigen. -->
    <style name="LabelSearchActivity" parent="Theme.AppCompat.Light.Dialog">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorPrimary</item>
        <item name="android:fontFamily">sans-serif-light</item>
    </style>

    <style name="DeleteButton" parent="GeneralText">
        <item name="android:background">@color/deletebutton</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_margin">10dp</item>
        <item name="android:text">Verwijderen</item>
        <item name="android:visibility">gone</item>
    </style>

    <style name="AlertIcon" parent="GeneralText">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginBottom">4dp</item>
        <item name="android:layout_marginRight">4dp</item>
        <item name="android:text">@string/fa_exclamation_triangle</item>
        <item name="android:textColor">#FFA500</item>
    </style>

    <style name="LabelSearchIcon" parent="GeneralText">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginBottom">4dp</item>
        <item name="android:layout_marginRight">25dp</item>
        <item name="android:layout_marginTop">6dp</item>
        <item name="android:text">@string/fa_info_circle</item>
        <item name="android:textColor">#001aff</item>
        <item name="android:textSize">30dp</item>
        <item name="android:visibility">gone</item>
    </style>

</resources>

activity_core.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- The ActionBar displayed at the top -->
        <include
            layout="@layout/app_bar_core"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ProgressBar
                android:id="@+id/main_progress_bar"
                style="@style/Widget.AppCompat.ProgressBar.Horizontal"
                android:layout_width="match_parent"
                android:layout_height="3dp"
                android:progressDrawable="@drawable/main_progress"
                android:visibility="gone"
                tools:visibility="visible"
                />
        <!-- The main content view where fragments are loaded -->
            <LinearLayout
                android:id="@+id/content_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" />
        </FrameLayout>
    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</android.support.v4.widget.DrawerLayout>

fragment_email_entity.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             xmlns:fab="http://schemas.android.com/apk/res-auto"
             tools:context=".view.email.EmailEntityFragment">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/email_entity_view"
        android:scrollbars="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>


</FrameLayout>

2 个答案:

答案 0 :(得分:2)

将其添加到AppTheme

中的style.xml
 <item name="windowActionModeOverlay">true</item>
 <item name="android:windowActionModeOverlay">true</item>

答案 1 :(得分:0)

我希望这是你的活动主题。添加<item name="windowActionModeOverlay">true</item>以获得ActionMode的叠加行为。

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="android:fontFamily">sans-serif-light</item>

    <item name="android:windowActionModeOverlay">true</item>
    <!-- Support compatibility -->
    <item name="windowActionModeOverlay">true</item>
</style>