我同时使用 CollapsingToolbarLayout、RecyclerView 和 SwipeRefreshLayout:
Xml:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/collapse_toolbar_height"
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:contentScrim="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/toolbar_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<include
layout="@layout/activity_main_toolbar"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<cz.yetanotherview.webcamviewer.app.helper.EmptyRecyclerView
android:id="@+id/mainList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/floating_action_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:layout_margin="16dp"
app:fabSize="mini"
android:src="@drawable/ic_action_edit"
android:onClick="assignSelectedWebCamsToCategory"/>
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/floating_action_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end"
android:paddingRight="10dp"
android:paddingBottom="8dp"
android:paddingLeft="10dp"
fab:menu_shadowColor="#37000000"
fab:menu_colorNormal="#DA4336"
fab:menu_colorPressed="#E75043"
fab:menu_colorRipple="#99FFFFFF"
fab:menu_icon="@drawable/fab_add"
fab:menu_buttonSpacing="10dp"
fab:menu_labels_textColor="@color/very_dark_grey"
fab:menu_labels_textSize="14sp"
fab:menu_labels_colorNormal="@color/white"
fab:menu_labels_colorPressed="@color/next_grey"
fab:menu_labels_colorRipple="#99FFFFFF"
fab:menu_labels_margin="8dp"
fab:menu_backgroundColor="@color/black_transparent">
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_content_import"
fab:fab_size="mini"
fab:fab_label="@string/pref_import_from_server"
fab:fab_colorNormal="@color/white"
app:fab_colorPressed="@color/next_grey"
app:fab_colorRipple="#99FFFFFF"
android:onClick="showSelectionDialog"/>
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_content_manually"
fab:fab_size="mini"
fab:fab_label="@string/create_manually"
fab:fab_colorNormal="@color/white"
app:fab_colorPressed="@color/next_grey"
app:fab_colorRipple="#99FFFFFF"
android:onClick="showAddDialog"/>
<com.github.clans.fab.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_content_suggestion"
fab:fab_size="mini"
fab:fab_label="@string/submit_suggestion"
fab:fab_colorNormal="@color/white"
app:fab_colorPressed="@color/next_grey"
app:fab_colorRipple="#99FFFFFF"
android:onClick="showSuggestionDialog"/>
</com.github.clans.fab.FloatingActionMenu>
</android.support.design.widget.CoordinatorLayout>
<include
layout="@layout/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
代码:
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeRefreshLayout.setOnRefreshListener(this);
当折叠工具栏布局完全展开并且 ScrollView (recyclerview)在顶部时,如何仅允许滑动刷新操作? Google+ 或 Inbox 应用程序中的类似行为。
错误:
好:
最佳答案
更新:此问题已在最新版本的支持库 (23.1.1+) 中得到解决。如果您使用的是旧版本的支持库,请升级或继续阅读。
如果您使用的是旧版本的支持库,请向您的 AppBarLayout 添加偏移量更改监听器,以相应地启用或禁用滑动以刷新布局。此处提供其他代码:
https://gist.github.com/blackcj/001a90c7775765ad5212
相关变化:
public class MainActivity extends AppCompatActivity implements AppBarLayout.OnOffsetChangedListener {
...
private AppBarLayout appBarLayout;
private SwipeRefreshLayout mSwipeRefreshLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.contentView);
appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout);
}
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
//The Refresh must be only active when the offset is zero :
mSwipeRefreshLayout.setEnabled(i == 0);
}
@Override
protected void onResume() {
super.onResume();
appBarLayout.addOnOffsetChangedListener(this);
}
@Override
protected void onPause() {
super.onPause();
appBarLayout.removeOnOffsetChangedListener(this);
}
}
关于Android:CollapsingToolbarLayout 和 SwipeRefreshLayout 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30779667/
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我是Ruby新手,在Ubuntu12.04机器上安装了Ruby1.9.3。每当我在终端中不带任何参数地运行ruby命令时,它就会挂起并且什么都不做。它在我的WindowsXP安装上做同样的事情。这是预期的行为吗?来自Python/Java背景,我期待某种输出。 最佳答案 这是预料之中的。当您只运行ruby时,它会停在那里,等待来自STDIN的程序,后跟一个文件结束符,然后执行该程序。如果你想要交互,比如当你运行python时,你需要Ruby的irb。 关于ruby-使用不带参数的'rub
运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid
1.前言 在10.0的系统rom定制化开发中,在系统中有多个launcher的时候,会在开机进入launcher的时候弹窗launcher列表,让用户选择进入哪个launcher,这样显得特别的不方便所以产品开发中,要求用RoleManager的相关api来设置默认Launcher,但是在设置完默认Launcher以后,在安装一款Launcher的时候,默认Launcher就会失效,在系统设置的默认应用中Launcher选项就为空,点击home键的时候会弹出默认Launcher列表,让选择进入哪个默认Launcher.所以需要从安装Launcher的流程来分析相关的设置。来解决问题设置默认La
Ai-Bot基于流行的Node.js和JavaScript语言的一款新自动化框架,支持Windows和Android自动化。1、Windowsxpath元素定位算法支持支持Windows应用、.NET、WPF、Qt、Java和Electron客户端程序和ie、edgechrome浏览器2、Android支持原生APP和H5界面,元素定位速度是appium十倍,无线远程自动化操作多台安卓设备3、基于opencv图色算法,支持找图和多点找色,1080*2340全分辨率找图50MS以内4、内置免费OCR人工智能技术,无限制获取图片文字和找字功能。5、框架协议开源,除官方node.jsSDK外,用户可
前一段时间由于工作需要把可爱的小雪狐舍弃了,找到了小蜜蜂。但是新版本的小蜜蜂出现了很多和旧版本不一样的位置。1.功能位置迁移,原来在工程build.gradle的buildscript和allprojects移动至setting.gradle并改名为pluginManagement和dependencyResolutionManagement。里面的东西依旧可以按照原来的copy过来。pluginManagement{repositories{gradlePluginPortal()google()mavenCentral()}}dependencyResolutionManagement{r
关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于StackOverflow来说是偏离主题的,因为它们往往会吸引自以为是的答案和垃圾邮件。相反,describetheproblem以及迄今为止为解决该问题所做的工作。关闭9年前。Improvethisquestion我几乎用完了Ruby,但现在想试试Ruboto,android上的ruby。谷歌未能给我足够的(几乎没有结果)。所以任何人都可以分享一些关于Ruboto的教程。
Aproblemoccurredconfiguringrootproject'MyApplication2'.>Couldnotresolveallfilesforconfiguration':classpath'. >Couldnotresolvecom.android.tools.build:gradle:7.4.2. Requiredby: project:>com.android.application:com.android.application.gradle.plugin:7.4.2 project:>com.android.library:com.andr
简介:我们都知道在Android开发中,当我们的程序在与用户交互时,用户会得到一定的反馈,其中以对话框的形式的反馈还是比较常见的,接下来我们来介绍几种常见的对话框的基本使用。前置准备:(文章最后附有所有代码)我们首先先写一个简单的页面用于测试这几种Dialog(对话框)代码如下,比较简单,就不做解释了一、提示对话框(即最普通的对话框)首先我们给普通对话框的按钮设置一个点击事件,然后通过AlertDialog.Builder来构造一个对象,为什么不直接Dialog一个对象,是因为Dialog是一个基类,我们尽量要使用它的子类来进行实例化对象,在实例化对象的时候,需要将当前的上下文传过去,因为我这
这是什么意思?在一个项目的说明中,它说“卡住Railsgems”。这与卡住Rails版本有何不同?什么是卡住? 最佳答案 如果您使用的gem的作者之一引入了该gem的新版本,则新版本可能会引入向后不兼容的更改,从而破坏您的代码。卡住gem会将其放入应用程序的vendor文件夹中,并且不会自行自动更新。Rails将使用此版本的gem。这允许您为其他应用程序更新系统上的gem,同时让您唯一的应用程序使用您一直使用的gem版本,因此是稳定的。这也适用于railsgem本身,因为较新版本的rails最终可能会导致您的应用程序中的某些内容崩溃