FlipViewPager.Draco
1.0.0
该项目旨在提供一个可在 ListView 中使用的工作翻页实现。产地:[Yalantis] (https://yalantis.com/?utm_source=github)
检查这个[Dribbble 上的项目] (https://dribbble.com/shots/1758298-Find-Friends-Interaction?list=users&offset=35)
在 [Youtube] (https://www.youtube.com/watch?v=zNRPjS53m5w) 上查看其工作原理
#用法
对于有效的实现,请查看示例项目 - 示例
要获得相同的网格视图,您应该:
将库包含为本地库项目:
compile ' com.yalantis:flipviewpager:1.0.0 '
创建您的主布局,它将是两个项目合并在一起的视图:
<!-- ... -->
< ImageView
android : id = " @+id/first "
xmlns : android = " http://schemas.android.com/apk/res/android "
android : layout_width = " 0dp "
android : layout_weight = " 1 "
android : contentDescription = " left image "
android : layout_height = " wrap_content "
android : scaleType = " fitXY " />
< LinearLayout
android : layout_width = " 1dp "
android : layout_weight = " 0 "
android : background = " #000000 "
android : layout_height = " fill_parent " />
< ImageView
android : id = " @+id/second "
android : layout_width = " 0dp "
android : layout_weight = " 1 "
android : contentDescription = " right image "
android : layout_height = " wrap_content "
android : scaleType = " fitXY " />
<!-- ... -->
创建布局以显示每个合并项目的附加信息:
<!-- ... -->
< com .yalantis.flip.sample.views.FontTextView
style = " @style/TextView.Nickname "
android : id = " @+id/nickname " />
< LinearLayout
android : layout_below = " @+id/nickname "
android : id = " @+id/interestsPrimary "
style = " @style/LinearLayout.Interests " >
< com .yalantis.flip.sample.views.FontTextView
style = " @style/TextView.Interest "
android : id = " @+id/interest_1 " />
<!-- ... -->
</ LinearLayout >
创建适配器并从BaseFlipAdapter<T>
扩展它
class FriendsAdapter extends BaseFlipAdapter < Friend > {
@ Override
public View getPage ( int position ,
View convertView ,
ViewGroup parent ,
Friend friend1 ,
Friend friend2 ) {
// ...
}
class FriendsHolder {
// ...
}
}
在ListView
中设置适配器
final ListView friends = ( ListView ) findViewById ( R . id . friends );
friends . setAdapter ( new FriendsAdapter ( this , Utils . friends , settings ));
您可以像在常规ListView
中一样处理点击
friends . setOnItemClickListener ( new AdapterView . OnItemClickListener () {
@ Override
public void onItemClick ( AdapterView <?> parent , View view , int position , long id ) {
Friend friend = ( Friend ) friends . getAdapter (). getItem ( position );
Toast . makeText ( FriendsActivity . this , friend . getNickname (), Toast . LENGTH_SHORT ). show ();
}
});
更多选项将很快添加:)
#定制
要自定义页面将首先显示 - 创建 FlipSettings 对象并将其传递到适配器中
FlipSettings settings = new FlipSettings . Builder (). defaultPage ( 1 ). build ();
#兼容性
如果您向我们发送使用我们组件的项目的链接,我们将非常高兴。只需发送电子邮件至 [email protected] 如果您对动画有任何疑问或建议,请告诉我们。
PS 我们将发布更多包含在代码中的精彩内容以及关于如何使 Android (iOS) 的 UI 变得更好的教程。敬请关注!
Copyright 2017, Yalantis
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.