所以我有一个 ImageView 作为背景,在它上面有一个 Horizontal RecyclerView,这里的事情是我希望 RecyclerView 从屏幕左侧的一半填充开始显示它的项目,这样你就可以完美地看到背景在开始和滚动项目时,您会隐藏图像/背景。
注意:检查 Play 商店以查看我要完成的任务。
所以我有这个工作:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000052"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/trybg5"
android:layout_gravity="left" />
<HorizontalScrollView
android:id="@+id/frag_home_gallery_recent_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:scrollbars="none"
android:layout_weight="1"
android:paddingBottom="@dimen/horizontalGallery_content_padding"
android:paddingTop="@dimen/horizontalGallery_content_padding">
<LinearLayout
android:id="@+id/frag_home_gallery_recientes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="150dp" />
</HorizontalScrollView>
</RelativeLayout>
我的观点是以编程方式扩大 HorizontalScrollView 内的布局,并且效果很好。但随着时间的推移,我决定迁移到 RecyclerView,但现在没有按预期工作。
出现背景,Recycler 开始向右半屏,但滚动时它不会滚动到屏幕左侧,它会隐藏在设置 padding 的位置..
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000052"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/trybg5"
android:layout_gravity="left" />
<FrameLayout
android:id="@+id/frag_home_gallery_recent_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:scrollbars="none"
android:layout_weight="1"
android:paddingBottom="@dimen/horizontalGallery_content_padding"
android:paddingTop="@dimen/horizontalGallery_content_padding">
<android.support.v7.widget.RecyclerView
android:background="@drawable/gallery_bg"
android:id="@+id/frag_home_gallery_recientes"
android:scrollbars="none"
android:paddingLeft="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</FrameLayout>
</RelativeLayout>
知道如何在 RecyclerView 中实现这种效果吗?
这是回收器的详细信息:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:id="@+id/discoContainer"
android:background="@drawable/gallery_bg"
android:layout_margin="5dp"
android:padding="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/containerDisco"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/logoDisco"
android:transitionName="DiscoId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:contentDescription="LogoDisco"
android:windowSharedElementsUseOverlay="false" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="a 600m tuyos"
android:padding="3dp"
android:layout_gravity="center_horizontal"
android:maxLines="1"
android:gravity="center_horizontal"
android:alpha="500"
android:background="#46000000"
android:textColor="@android:color/white"/>
</RelativeLayout>
<TextView
android:id="@+id/logoTexto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Probando"
android:padding="3dp"
android:layout_gravity="center_horizontal"
android:maxLines="1"
android:gravity="center_horizontal"
android:layout_alignBottom="@+id/containerDisco" />
</LinearLayout>
</LinearLayout>
最佳答案
比这简单多了,RecyclerView 已经有了这个功能:只需将 android:clipToPadding="false" 设置为 RecyclerView XML,这样填充物就不会剪掉您的元素。
所以对于你的例子:
<android.support.v7.widget.RecyclerView
android:background="@drawable/gallery_bg"
android:id="@+id/frag_home_gallery_recientes"
android:scrollbars="none"
android:paddingLeft="150dp"
android:clipToPadding="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
关于android - 具有起始填充的水平 RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34295173/
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我有一个驼峰式字符串,例如:JustAString。我想按照以下规则形成长度为4的字符串:抓取所有大写字母;如果超过4个大写字母,只保留前4个;如果少于4个大写字母,则将最后大写字母后的字母大写并添加字母,直到长度变为4。以下是可能发生的3种情况:ThisIsMyString将产生TIMS(大写字母);ThisIsOneVeryLongString将产生TIOV(前4个大写字母);MyString将生成MSTR(大写字母+tr大写)。我设法用这个片段解决了前两种情况:str.scan(/[A-Z]/).first(4).join但是,我不太确定如何最好地修改上面的代码片段以处理最后一种
我正在使用Rails3.1并在一个论坛上工作。我有一个名为Topic的模型,每个模型都有许多Post。当用户创建新主题时,他们也应该创建第一个Post。但是,我不确定如何以相同的形式执行此操作。这是我的代码:classTopic:destroyaccepts_nested_attributes_for:postsvalidates_presence_of:titleendclassPost...但这似乎不起作用。有什么想法吗?谢谢! 最佳答案 @Pablo的回答似乎有你需要的一切。但更具体地说...首先改变你View中的这一行对此#
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我从用户Hirolau那里找到了这段代码:defsum_to_n?(a,n)a.combination(2).find{|x,y|x+y==n}enda=[1,2,3,4,5]sum_to_n?(a,9)#=>[4,5]sum_to_n?(a,11)#=>nil我如何知道何时可以将两个参数发送到预定义方法(如find)?我不清楚,因为有时它不起作用。这是重新定义的东西吗? 最佳答案 如果您查看Enumerable#find的文档,您会发现它只接受一个block参数。您可以将它发送两次的原因是因为Ruby可以方便地让您根据它的“并行赋
RSpec似乎按顺序匹配方法接收的消息。我不确定如何使以下代码工作:allow(a).toreceive(:f)expect(a).toreceive(:f).with(2)a.f(1)a.f(2)a.f(3)我问的原因是a.f的一些调用是由我的代码的上层控制的,所以我不能对这些方法调用添加期望。 最佳答案 RSpecspy是测试这种情况的一种方式。要监视一个方法,用allowstub,除了方法名称之外没有任何约束,调用该方法,然后expect确切的方法调用。例如:allow(a).toreceive(:f)a.f(2)a.f(1)
我有一个模块stat存在于目录结构中:lib/stat_creator/stat/在lib/stat_creator/stat.rb中,我在lib/stat_creator/stat/目录中有我需要的文件,以及:moduleStatCreatormoduleStatendend当我使用该模块时,我将这些类称为StatCreator::Stat::Foo.new现在我想要一个存在于应用程序中的根Stat类。我在app/models中制作了我的Stat类,并在routes.rb中进行了设置。但是,如果我转到Rails控制台并尝试在应用程序/模型中使用Stat类,例如:Stat.by_use
我正在尝试按Rails相关模型中的字段进行排序。我研究的所有解决方案都没有解决如果相关模型被另一个参数过滤?元素模型classItem相关模型:classPriority我正在使用where子句检索项目:@items=Item.where('company_id=?andapproved=?',@company.id,true).all我需要按相关表格中的“位置”列进行排序。问题在于,在优先级模型中,一个项目可能会被多家公司列出。因此,这些职位取决于他们拥有的company_id。当我显示项目时,它是针对一个公司的,按公司内的职位排序。完成此任务的正确方法是什么?感谢您的帮助。PS-我
我想用sunspot重现以下原始solr查询q=exact_term_text:fooORterm_textv:foo*ORalternate_text:bar*但我无法通过标准的太阳黑子界面理解这是否可能以及如何实现,因为看起来:fulltext方法似乎不接受多个文本/搜索字段参数我不知道将什么参数作为第一个参数传递给fulltext,就好像我通过了"foo"或"bar"结果不匹配如果我传递一个空参数,我得到一个q=*:*范围过滤器(例如with(:term).starting_with('foo*')(顾名思义)作为过滤器查询应用,因此不参与评分。似乎可以手动编写字符串(或者可能使