高仿iReader书架效果
阅读过电子书的朋友相信对iReader都是比较熟悉的,iReader的书架做的非常漂亮,以前总以为是使用了2D画图做的呢,今天反编译了一下才明白原来是用图片拼接起来的,这样就OK了,今天我就带大家实现一个iReader书架。
首先看一下layout下main.xml布局:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/bookshelf_header_bg" >
- <ImageView
- android:id="@+id/shelf_image_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:background="@drawable/bookshelf_header_logo" />
- <Button
- android:id="@+id/shelf_image_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:background="@drawable/bookshelf_goto_bookcity_f" />
- </RelativeLayout>
- <ListView
- android:id="@+id/shelf_list"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:scrollbars="none"
- android:divider="#00000000"
- android:cacheColorHint="#00000000"/>
- </LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bookshelf_header_bg" >
<ImageView
android:id="@+id/shelf_image_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/bookshelf_header_logo" />
<Button
android:id="@+id/shelf_image_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="@drawable/bookshelf_goto_bookcity_f" />
</RelativeLayout>
<ListView
android:id="@+id/shelf_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:divider="#00000000"
android:cacheColorHint="#00000000"/>
</LinearLayout>
由于书架是用图片拼成的,所以每一个行的数据框都是一个listview , 看一些listview对应的item布局:
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
- <ImageView
- android:id="@+id/shelf_image_left"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:background="@drawable/bookshelf_layer_left" />
- <LinearLayout
- android:id="@+id/linearLayout1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_toLeftOf="@+id/shelf_image_right"
- android:layout_toRightOf="@+id/shelf_image_left"
- android:background="@drawable/bookshelf_layer_center"
- android:orientation="horizontal" >
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center_horizontal" >
- <Button
- android:id="@+id/button_1"
- android:layout_width="80dip"
- android:layout_height="110dip"
- android:layout_marginTop="15dip"
- android:background="@drawable/default_cover" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center_horizontal" >
- <Button
- android:id="@+id/button_2"
- android:layout_width="80dip"
- android:layout_height="110dip"
- android:layout_marginTop="15dip"
- android:background="@drawable/default_cover" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:gravity="center_horizontal" >
- <Button
- android:id="@+id/button_3"
- android:layout_width="80dip"
- android:layout_height="110dip"
- android:layout_marginTop="15dip"
- android:background="@drawable/default_cover" />
- </LinearLayout>
- </LinearLayout>
- <ImageView
- android:id="@+id/shelf_image_right"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:background="@drawable/bookshelf_layer_right" />
- </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/shelf_image_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="@drawable/bookshelf_layer_left" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/shelf_image_right"
android:layout_toRightOf="@+id/shelf_image_left"
android:background="@drawable/bookshelf_layer_center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
<Button
android:id="@+id/button_1"
android:layout_width="80dip"
android:layout_height="110dip"
android:layout_marginTop="15dip"
android:background="@drawable/default_cover" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
<Button
android:id="@+id/button_2"
android:layout_width="80dip"
android:layout_height="110dip"
android:layout_marginTop="15dip"
android:background="@drawable/default_cover" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal" >
<Button
android:id="@+id/button_3"
android:layout_width="80dip"
android:layout_height="110dip"
android:layout_marginTop="15dip"
android:background="@drawable/default_cover" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/shelf_image_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/bookshelf_layer_right" />
</RelativeLayout>
最后是把item绑定到listview中:
- package cn.com.karl.reader;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.view.Window;
- import android.widget.BaseAdapter;
- import android.widget.ListView;
- public class IReaderActivity extends Activity {
- /** Called when the activity is first created. */
- private ListView shelf_list;
- // 书架的列数
- int[] size = new int[5];
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.main);
- shelf_list = (ListView) findViewById(R.id.shelf_list);
- ShelfAdapter adapter = new ShelfAdapter();
- shelf_list.setAdapter(adapter);
- }
- public class ShelfAdapter extends BaseAdapter {
- @Override
- public int getCount() {
- // TODO Auto-generated method stub
- return size.length;
- }
- @Override
- public Object getItem(int position) {
- // TODO Auto-generated method stub
- return size[position];
- }
- @Override
- public long getItemId(int position) {
- // TODO Auto-generated method stub
- return position;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- // TODO Auto-generated method stub
- View layout = LayoutInflater.from(getApplicationContext()).inflate(
- R.layout.list_item, null);
- return layout;
- }
- }
- }
package cn.com.karl.reader;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.ListView;
public class IReaderActivity extends Activity {
/** Called when the activity is first created. */
private ListView shelf_list;
// 书架的列数
int[] size = new int[5];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
shelf_list = (ListView) findViewById(R.id.shelf_list);
ShelfAdapter adapter = new ShelfAdapter();
shelf_list.setAdapter(adapter);
}
public class ShelfAdapter extends BaseAdapter {
@Override
public int getCount() {
// TODO Auto-generated method stub
return size.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return size[position];
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View layout = LayoutInflater.from(getApplicationContext()).inflate(
R.layout.list_item, null);
return layout;
}
}
}
每一本书对应的点击事件这里并没有做,相信大家可以实现,OK,下面看一下运行后效果:
高仿iReader书架效果相关推荐
- vue高仿立体卡片效果(第一版)
如图所示: 代码如下:(复制另存txt,修改.html直接运行) <!DOCTYPE html> <html> <head><meta charset=&qu ...
- vue高仿立体卡片效果(第二版)
组件 如图所示: 下载地址:TAB组件 在此基础修改:vue高仿立体卡片效果(第一版) 更新记录: 1.0 修复中间分割线ios端异常,放弃border-image采用after伪元素实现
- vue高仿立体卡片效果(第三版)
组件 如图所示: 使用方法 <template><div class="Home w100 h100"><!-- tab切换 start --> ...
- 仿ireader书架
2019独角兽企业重金招聘Python工程师标准>>> public class ReaderActivity extends Activity {private ShelfAdap ...
- ireader android 源码,仿ireader书架 - androidCode的个人空间 - OSCHINA - 中文开源技术交流社区...
public class ReaderActivity extends Activity { private ShelfAdapter mAdapter; // 书架列表 private ListVi ...
- Android-通过SlidingPaneLayout高仿微信6.2最新版手势滑动返回(一)
最近更新了微信版本到6.2,发现里面有个非常好的体验,就是在第二个页面Activity能手势向右滑动返回,在手势滑动的过程中能看到第一个页面,这种体验非常赞,这里高仿了一下.这里使用的是v4包里面的S ...
- HTML5 Canvas 高仿逼真 3D 布料图案效果
HTML5 规范引进了很多新特性,其中最令人期待的之一就是 Canvas 元素,HTML5 Canvas 提供了通过 JavaScript 绘制图形的方法,非常强大.下面给大家分享一个 HTML5 C ...
- iOS高仿微信项目、阴影圆角渐变色效果、卡片动画、波浪动画、路由框架等源码...
2019独角兽企业重金招聘Python工程师标准>>> iOS精选源码 iOS高仿微信完整项目源码 Khala: Swift 编写的iOS/macOS 路由框架 微信左滑删除效果的实 ...
- 高仿阴阳师官网轮播图效果的jQuery插件
代码地址如下: http://www.demodashi.com/demo/12302.html 插件介绍 这是一个根据阴阳师官网的轮播效果所扒下来的轮播插件,主要应用于定制个性化场景,目前源码完全公 ...
最新文章
- 回文数猜想代码c语言,跪求用C++写出回文数猜想程序,课程设计需要,谢谢。。。...
- mui汉字图标_MUI从入门到项目实战(三)增加自定义icon图标
- 方程的解_NOI导刊2010提高(01) 组合数
- ActiveMQ(07):ActiveMQ结合Spring开发--建议
- Catch That Cow(POJ-3278)
- 云小课 | 云硬盘不用了如何处理?
- Vivado入门创建工程之----自定义ip及其使用
- 孙燕姿:(Hello, I'm Stefanie...)
- 华为培训视频-AAA培训
- Selenium+JAVA淘宝登录、商品搜索、添加收货地址,提交订单、付款流程(UI)
- 无插件播放之http-flv
- phython day1
- mac游戏排行榜,mac好玩的游戏推荐 (一)
- IT程序员的抉择:我要离开帝都了
- DH 加密算法的使用
- 老照片修复的方法哪个好用?老照片修复技巧分享
- 基于freemarker(mht)方式导出带图片的富文本word
- 环己酰亚胺:一种细菌毒素的相关研究
- 行业案例 | 易安联零信任SDP解决方案,让企业经营更高效
- 百度竞价点击器_【竞价推广100问】百度竞价点击怎么收费,有计算公式吗?
热门文章
- 《新建文本文档》贾瑜
- Ubuntu 16.04 64位+Qt 5.7.1+opencv 3.2.0 + opencv_contrib 3.2.0
- C练题笔记之:Leetcode-654. 最大二叉树
- 常见行内元素、块级元素、行内块元素
- Win11系统.NET Framework 3.5怎么启用?
- Python新建、写入和修改txt(文本文档)
- 你了解HashMap吗?
- 攻防世界sherlock
- opencv 照片动漫风格
- 猫眼电影院爬虫(可用)