在ListView上,您可以使用快速滚动条,允许您拖动滚动条以轻松滚动到您希望的任何位置(使用fastScrollEnabled属性)
与" SectionIndexer "类和可选的一些属性一起,您可以在使用此滚动条时显示一个很好的弹出窗口(此处链接).
联系人应用程序上会显示这样的内容,以便您可以轻松滚动到特定字母.
RecyclerView似乎没有任何这些.甚至不是快速滚动.
如何为RecyclerView添加快速滚动功能?
android scrollbar fastscroll sectionindexer android-recyclerview
我列出了按月和年分开的活动清单(2010年6月,2010年7月等)
我想启用快速滚动,因为列表非常长.
如何ListViews
在Android中启用快速滚动?
在我的应用程序中,我有这样的activity_main.xml: -
<Coordinator Layout>
<AppBarLayout>
<CollapsingToolbarLayout>
<ImageView/>
<Toolbar/>
</CollapsingToolbarLayout>
</AppBarLayout>
<RecyclerView/>
</Coordinating Layout>
Run Code Online (Sandbox Code Playgroud)
Layout.xml ----- >>>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/theme_background"
android:id="@+id/drawerlayout"
>
<android.support.design.widget.CoordinatorLayout 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"
android:fitsSystemWindows="true"
android:id="@+id/activity_main_id"
tools:context="objectdistance.ajai.ram.sita.gallery.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true">
<ImageView
android:id="@+id/imagetoolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
android:foreground="@drawable/image_header_foreground"
app:layout_scrollFlags="scroll"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="@drawable/theme_background"
app:layout_collapseMode="pin" >
<Spinner
android:id="@+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dropDownVerticalOffset="?attr/actionBarSize" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list" …
Run Code Online (Sandbox Code Playgroud) android fastscroll material-design android-recyclerview android-coordinatorlayout
我有一个实现的类expandable list activity
.
在XML代码中(或者我可以在java中完成),我设置fastScrollEnabled
为true
.这样做可以实现快速滚动.但快速滚动仅适用于列表的顶部.就像我可以使用fastscroll拇指栏滚动整个列表,但只能在滚动条的顶部工作.它与整个列表不成比例.我可以将拇指栏拖动到列表的底部,但它不会滚动,因为listview
它已经滚动到底部,因为它的奇怪行为只能在列表的顶部工作.
令我感到困惑,如果需要,我可以尝试澄清更多......
我确实实现了一个自定义 BaseExpandableListAdapter.
我正在使用expandablelistview来显示包含不同子项数的组列表.有时列表很长,所以我想启用fastscroll.我做了这个,当我用通常的方式用手指滚动列表时一切正常.
但当我抓住拇指并将其拖到底部时,当我将拇指从顶部移动大约1/3的高度时,列表会滚动到最后位置.如何让拇指根据滚动条的整个高度定位列表?
我正在使用ListView来实现时间轴.我启用了FastScroll并使用了SectionIndexer,以便用户可以拖动滚动条并查看显示的部分文本.
问题是所有这些都是内置的UI.显示部分文本的textview对我来说太小了,我试图显示05pm并且它对于textview(或其他UI?)来说太长了.
有什么更简单的方法来解决这个 例如,我可以设置一个方法来设置剖面文本或textview布局的字体大小?
谢谢!
我有一个具有全息外观的应用程序.
对于pre-Honeycomb设备,我只是向后推出了Holo主题的一些元素.
使用主题,样式和attrs适用于CheckBox,RadioButton ......
我使用ListView来显示很多项目.我想在我的ListView上启用快速滚动,我希望它具有全息外观.
我有一些困难将快速滚动Drawable它集成到我的应用主题中.
寻找能够做到这一点的图书馆. HoloEverywhere很有希望,但没有处理.
试图自己做:
我刚刚添加了那些drawable:
然后还添加了这个drawable:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/fastscroll_thumb_pressed_holo" />
<item android:drawable="@drawable/fastscroll_thumb_default_holo" />
</selector>
Run Code Online (Sandbox Code Playgroud)
在我的添加中attrs.xml
:
<attr name="fastScrollThumbDrawable" format="reference" />
Run Code Online (Sandbox Code Playgroud)
我在我的中添加了这个themes.xml
:
<style name="MyTheme">
<item name="fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
</style>
Run Code Online (Sandbox Code Playgroud)
此主题已正确设置为我的应用程序Manifest.xml
:
android:theme="@style/MyTheme"
Run Code Online (Sandbox Code Playgroud)
请记住android:fastScrollThumbDrawable
蜂窝前不存在.
我希望你能帮我解决这个问题.:)
更新:
几个小时前,HoloEverywhere已经添加了快速滚动支持:
https://github.com/ChristopheVersieux/HoloEverywhere/commit/34561e48339bf6a3e0307d2d35fc4c5ac8409310
我会检查一下.:)
android android-layout fastscroll android-theme android-holo-everywhere
我使用以下属性实现了 RecyclerView 快速滚动:
<android.support.v7.widget.RecyclerView
...
app:fastScrollEnabled="true"
app:fastScrollHorizontalThumbDrawable="@drawable/fast_scroll_thumb"
app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track"
app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb"
app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track"/>
Run Code Online (Sandbox Code Playgroud)
fast_scroll_thumb.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/lightBlue" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/lightBlue" />
</shape>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
fast_scroll_track.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/gray" />
</shape>
Run Code Online (Sandbox Code Playgroud)
但是,快速滚动拇指大小取决于数据数量。随着 RecyclerView 数据的增加,拇指大小减小。有没有办法将拇指大小固定在固定高度?
这是我的列表视图
<ListView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/ListView"
android:fastScrollEnabled="true" android:divider="@null"
style="@drawable/listviewfastscrollstyle"
></ListView>
Run Code Online (Sandbox Code Playgroud)
这是listviewfastscrollstyle样式文件
<style>
<item name="android:fastScrollTrackDrawable">@drawable/listselector</item>
<item name="android:fastScrollThumbDrawable">@drawable/listselector</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是listselector文件
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/channelarrows_down" />
<item android:drawable="@drawable/minimize" />
</selector>
Run Code Online (Sandbox Code Playgroud)
但仍然列表视图快速滚动条没有得到定制.
我有一个ListView
具有fastScroll
始终处于启用状态和SwipeRefresh
执行.当我向下滑动列表时,它会刷新列表.我的问题是fastScroll
.如果列表的第一个项目可见或在其最初的顶部显示,那么如果向下滚动fastScrollThumb
,它会产生Swipe
效果而不是向下滚动.无论如何/解决方案,如果我按fastScrollThumb
,然后它不应该做Swipe
刷新效果,而是它应该向下滚动,因为它的自然行为.
编辑
我XML Layout
的如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/buttons_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/neoo_tab_selector" />
</RelativeLayout>
<ListView
android:id="@id/android:list"
style="@style/NeeoContactListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/buttons_layout"
android:layout_marginTop="10dp" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)
我Logic for onScroll
启用/禁用的SwipeRefresh
是:
getListView().setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public …
Run Code Online (Sandbox Code Playgroud)