仿百度壁纸客户端(六)——完结篇之Gallery画廊实现壁纸预览已经项目细节优化


百度壁纸系列

仿百度壁纸客户端(一)——主框架搭建,自定义Tab + ViewPager + Fragment

仿百度壁纸客户端(二)——主页自定义ViewPager广告定时轮播图

仿百度壁纸客户端(三)——首页单向,双向事件冲突处理,壁纸列表的实现

仿百度壁纸客户端(四)——自定义上拉加载实现精选壁纸墙

仿百度壁纸客户端(五)——实现搜索动画GestureDetector手势识别,动态更新搜索关键字

仿百度壁纸客户端(六)——完结篇之Gallery画廊实现壁纸预览已经项目细节优化


我们这里有一个细节还没有实现,我们先看一下官方的效果

这个学名叫做Gallery画廊,我们今天也来实现它,我们在精选的Fragment中给GradView设置点击事件,让他跳转到画廊,实际开发当中是获取当前点击的图片的,这里我们就只能模拟图片了

myGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {startActivity(new Intent(getActivity(), GalleryActivity.class));}});

跳转的Activity就是我们今天来实现的,我们先来下个布局

layout_gallery.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/image_home_background"><Gallery
        android:id="@+id/myGallery"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true" /><LinearLayout
        android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:gravity="center_horizontal"android:orientation="vertical"><LinearLayout
            android:layout_width="150dp"android:layout_height="wrap_content"android:gravity="center"android:orientation="horizontal"><ImageView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/image_view_button_set_as_wallpaper" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="center"android:text="设置壁纸"android:textColor="#fff" /></LinearLayout><LinearLayout
            android:layout_width="match_parent"android:layout_height="50dp"android:orientation="horizontal"><LinearLayout
                android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"><ImageView
                    android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/image_view_button_preview" /><TextView                    android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="预览"android:textColor="#fff" /></LinearLayout><LinearLayout
                android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"><ImageView
                    android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/image_view_button_download" /><TextView                    android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="下載"android:textColor="#fff" /></LinearLayout><LinearLayout
                android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"><ImageView
                    android:layout_width="wrap_content"android:layout_height="match_parent"android:src="@drawable/image_view_button_share" /><TextView                    android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="分享"android:textColor="#fff" /></LinearLayout></LinearLayout></LinearLayout></RelativeLayout>

然后开始实现了,这个不是什么难的技术,只是一个容器,我们还得定义一个Adapter,这里直接放上代码,毕竟就几行代码

package com.lgl.baiduwallpaper;import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;import java.util.ArrayList;/*** 画廊效果* Created by lgl on 16/4/9.*/
public class GalleryActivity extends Activity {//画廊private Gallery mGallery;private ArrayList<Integer> srcData = new ArrayList<>();@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.layout_gallery);init();}private void init() {mGallery = (Gallery) findViewById(R.id.myGallery);initData();mGallery.setAdapter(new myAdapter(this));}/*** 初始化数据*/private void initData() {//这里模拟四张,实际开发中需要自己去获取srcData.add(R.mipmap.img1);srcData.add(R.mipmap.img2);srcData.add(R.mipmap.img3);srcData.add(R.mipmap.img4);}private class myAdapter extends BaseAdapter {private Context mContext;public myAdapter(Context mContext) {this.mContext = mContext;}@Overridepublic int getCount() {return srcData.size();}@Overridepublic Object getItem(int position) {return srcData.get(position);}@Overridepublic long getItemId(int position) {return position;}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {ImageView imageView = new ImageView(mContext);imageView.setBackgroundResource(srcData.get(position));imageView.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.MATCH_PARENT, Gallery.LayoutParams.WRAP_CONTENT));return imageView;}}
}

记得在清单文件注册哦

我们来运行一下

项目细节处理

换上LOGO

这个项目还是得按流畅来一遍,所以,引导页少不了的

IndexActivity

package com.lgl.baiduwallpaper;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;/*** Created by lgl on 16/4/9.*/
public class IndexActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_index);new Thread(new Runnable() {@Overridepublic void run() {try {Thread.sleep(2000);startActivity(new Intent(IndexActivity.this, MainActivity.class));finish();} catch (InterruptedException e) {e.printStackTrace();}}}).start();}
}

对应的布局

activity_index.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/welcome_bg"><TextView
        android:id="@+id/tv_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_marginTop="30dp"android:text="百度壁纸"android:textSize="50dp" /><TextView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/tv_title"android:layout_centerHorizontal="true"android:layout_marginTop="10dp"android:text="每天换壁纸,天天好心情" /><ImageView
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:src="@drawable/welcome_bottom" /></RelativeLayout>

运行结果

接下来,我们把title完善一下,首先是精选

<RelativeLayout
        android:id="@+id/rl_title"android:layout_width="match_parent"android:layout_height="50dp"android:alpha="0.8"android:background="#000"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="精选"android:textColor="#fff"android:textSize="16sp" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="10dp"android:text="刷新"android:textColor="#fff"android:textSize="16sp" /></RelativeLayout>

然後就是搜索了

<RelativeLayout
        android:id="@+id/rl_title"android:layout_width="match_parent"android:layout_height="50dp"android:alpha="0.8"android:background="#000"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="搜索"android:textColor="#fff"android:textSize="16sp" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="10dp"android:text="确定"android:textColor="#fff"android:textSize="16sp" /></RelativeLayout><RelativeLayout
        android:id="@+id/rl_search"android:layout_width="match_parent"android:layout_height="50dp"android:layout_below="@+id/rl_title"android:layout_margin="10dp"><EditText
            android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/image_search_button" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="10dp"android:src="@drawable/image_search_clear_button_selected" /></RelativeLayout>

接著是本地,本地我们不实现它的功能,就写个布局吧

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><RelativeLayout
        android:id="@+id/rl_title"android:layout_width="match_parent"android:layout_height="50dp"android:alpha="0.8"android:background="#000"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="本地"android:textColor="#fff"android:textSize="16sp" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="10dp"android:text="删除"android:textColor="#fff"android:textSize="16sp" /></RelativeLayout><LinearLayout
        android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/image_manage_no_wallpaper_logo" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="你本地还没有壁纸,快来下载些吧!" /><Button
            android:background="@drawable/button_pressed"android:layout_width="100dp"android:layout_height="50dp"android:layout_marginTop="30dp"android:text="精选"android:textColor="#fff" /></LinearLayout>
</LinearLayout>

最後就是設置了

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_margin="10dp"android:orientation="vertical"><RelativeLayout
        android:id="@+id/rl_title"android:layout_width="match_parent"android:layout_height="50dp"android:alpha="0.8"android:background="#000"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="设置"android:textColor="#fff"android:textSize="16sp" /><TextView
            android:visibility="gone"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:layout_marginRight="10dp"android:text="确定"android:textColor="#fff"android:textSize="16sp" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="自动更换壁纸" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="一鍵更换壁纸" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="图片浏览之类" /><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:text="自动" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="清除缓存" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item"android:visibility="invisible" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="检查更新" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item"android:visibility="invisible" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:layout_marginTop="30dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="帮助手册" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="意见反馈" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item" /></RelativeLayout><RelativeLayout
        android:layout_width="match_parent"android:layout_height="50dp"android:background="@drawable/image_more_subitems_bottom"android:gravity="center_vertical"><TextView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:text="关于我们" /><ImageView
            android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_marginRight="10dp"android:src="@drawable/image_list_open_item" /></RelativeLayout></LinearLayout>

我们完整的预览一遍

感兴趣的可以下载Demo玩玩

Demo下载:http://download.csdn.net/detail/qq_26787115/9485945

仿百度壁纸客户端(六)——完结篇之Gallery画廊实现壁纸预览已经项目细节优化...相关推荐

  1. 仿百度壁纸客户端(六)——完结篇之Gallery画廊实现壁纸预览已经项目细节优化

    仿百度壁纸客户端(六)--完结篇之Gallery画廊实现壁纸预览已经项目细节优化 百度壁纸系列 仿百度壁纸客户端(一)--主框架搭建,自定义Tab + ViewPager + Fragment 仿百度 ...

  2. 仿百度壁纸client(六)——完结篇之Gallery画廊实现壁纸预览已经项目细节优化...

    仿百度壁纸client(六)--完结篇之Gallery画廊实现壁纸预览已经项目细节优化 百度壁纸系列 仿百度壁纸client(一)--主框架搭建,自己定义Tab + ViewPager + Fragm ...

  3. 仿百度html页面,HTML实战篇:html仿百度首页

    原标题:HTML实战篇:html仿百度首页 本篇文章主要给大家介绍一下如何使用html+css来制作百度首页页面. 1)制作页面所用的知识点 我们首先来分析一下百度首页的页面效果图 百度首页由头部的一 ...

  4. 安卓IOS客户端调试webview页面的方法,支持实时预览

    调试方式 手机模拟器调试 真实手机调试,安卓和IOS都可以 注意事项 混合开发的时候经常要用到调试功能,调试webview方法有很多种: 直接让客户端把地址修改成本机ip地址,客户端重新出调试包 通过 ...

  5. 利用Python进行百度文库内容爬取(二)——自动点击预览全文并爬取

    本文是衔接上一篇:<利用Python进行百度文库内容爬取(一)>. 上回说到我们在对百度文库进行爬虫时,需要模拟手机端来进行登录,这样固然可以对文章进行爬取,但是很多时候并不是非常智能的翻 ...

  6. 仿百度壁纸客户端(四)——自定义上拉加载实现精选壁纸墙

    仿百度壁纸客户端(四)--自定义上拉加载实现精选壁纸墙 百度壁纸系列 仿百度壁纸客户端(一)--主框架搭建,自定义Tab + ViewPager + Fragment 仿百度壁纸客户端(二)--主页自 ...

  7. 仿百度壁纸客户端(三)——首页单向,双向事件冲突处理,壁纸列表的实现

    仿百度壁纸客户端(三)--首页单向,双向事件冲突处理,壁纸列表的实现 百度壁纸系列 仿百度壁纸客户端(一)--主框架搭建,自定义Tab + ViewPager + Fragment 仿百度壁纸客户端( ...

  8. 仿百度壁纸客户端(三)——首页单向,双向事件冲突处理,壁纸列表的实现...

    仿百度壁纸客户端(三)--首页单向,双向事件冲突处理,壁纸列表的实现 百度壁纸系列 仿百度壁纸客户端(一)--主框架搭建,自定义Tab + ViewPager + Fragment 仿百度壁纸客户端( ...

  9. 仿百度壁纸客户端(一)——主框架搭建,自定义Tab+ViewPager+Fragment

    仿百度壁纸客户端(一)--主框架搭建,自定义Tab+ViewPager+Fragment 百度壁纸系列 仿百度壁纸客户端(一)--主框架搭建,自定义Tab + ViewPager + Fragment ...

最新文章

  1. 《JVM系列》深入浅出类加载机制中<init>和<Clinit>的区别【一篇即可搞懂初始化机制】
  2. git clone 失败
  3. 第六节: EF高级属性(二) 之延迟加载、立即加载、显示加载(含导航属性)
  4. 掌握这个套路,让你的可视化大屏万里挑一
  5. FPGA同步复位异步复位
  6. hadoop集群的搭建与配置(2)
  7. SQL 必知必会·笔记6使用数据处理函数
  8. 原版98启动盘镜像.img_【教程】利用Windows 10 官方下载工具下载最新系统镜像、制作启动盘...
  9. redis 可视化客户端工具
  10. 基于SSM+Vue+OSS的“依伴汉服”商城设计与开发(含源码+论文+ppt+数据库)
  11. IP地址分类及对应范围
  12. MPI编程(3)—点对点通信(阻塞式MPI_Send/MPI_Recv和非阻塞式MPI_Isend/MPI_Irecv)
  13. PUG转HTML格式
  14. js实现缓慢回到页面顶部
  15. c# 之API获取进程用户名。
  16. Java 如何把gb2312编码转化为汉字(互转)
  17. arcgis把jpg转成栅格图像_[转载]在ArcGIS中配准(TIF、JPEG)栅格图像并矢量化(转)...
  18. 《30岁前的每一天》读书笔记
  19. TCP/IP协议号和端口
  20. Ubuntu16.04完全卸载Mysql 5.7

热门文章

  1. QT编写简易截图工具
  2. 大学生创业学习软件---学硕创业实训教学软件
  3. 人工智能市值排名 2020_苹果市值万亿美元,相当于37个小米,几个华为?
  4. uint 正数 与 int 负数 相加,会变成很大的正数
  5. 这才是年度旗舰机皇!心系天下三星W21 5G发布
  6. 关于Linux安装Vame tools工具步骤
  7. 关于STM32F407 PWM的理解
  8. 由火车站戴口罩人脸识别入站感想
  9. 超星python程序设计答案_超星Python程序设计免费答案
  10. 电子书 鸟哥的Linux私房菜 (基础学习篇 第三版).pdf