Android音乐、视频类APP常用控件:DraggablePanel(1)

Android的音乐视频类APP开发中,常涉及到用户拖曳视频、音乐播放器产生一定交互响应的设计需求,最典型的以YouTube APP为例。

YouTube在开发中,有用到一个第三方开源的可拖曳面板:DraggablePanel。DraggablePanel在github上的项目主页:https://github.com/pedrovgs/DraggablePanel


DraggablePanel的设计效果如动图所示,动图查看链接:https://github.com/pedrovgs/DraggablePanel/tree/develop/art

写一个DraggableView的小例子。

测试的主activity MainActivity.java:

package zhangphil.demo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); String[] data1 = new String[50];
for (int i = 0; i < data1.length; i++)
data1[i] = "item:" + i; ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, data1);
ListView mainListView = (ListView) findViewById(R.id.mainListView);
mainListView.setAdapter(adapter1); ListView secondListView = (ListView) findViewById(R.id.secondListView);
String[] data2 = { "Z", "H", "A", "N", "G", "P", "H", "I", "L" };
ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1,
data2);
secondListView.setAdapter(arrayAdapter);
}
}

布局文件activity_main.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" > <ListView
android:id="@+id/mainListView"
android:layout_width="match_parent"
android:layout_height="match_parent" /> <!-- Draggable View -->
<com.github.pedrovgs.DraggableView
xmlns:draggable_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/draggable_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
draggable_view:bottom_view_id="@+id/secondListView"
draggable_view:top_view_id="@+id/image"
draggable_view:top_view_margin_bottom="20dip"
draggable_view:top_view_margin_right="20dip"
draggable_view:top_view_x_scale_factor="2.0"
draggable_view:top_view_y_scale_factor="2.0" > <ListView
android:id="@+id/secondListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/image"
android:background="#EF5350" /> <ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="200dip"
android:layout_alignParentTop="true"
android:background="#42A5F5"
android:src="@drawable/ic_launcher" /> </com.github.pedrovgs.DraggableView> </RelativeLayout>

代码运行结果:

初始化状态:

向下拖曳时候渐变:

拖曳到最底部的情形:

又拖曳机器人向上:

mainListView在一定程度上可以理解为“背景全部数据”。

DraggableView将是随用户拖曳产生交互响应的面板,在DraggableView里面,再套两层Android View,本例是一个简单的ImageView和一个ListView,ImageView在上,ListView在下,这两者套在DraggableView里面,随用户的拖曳动作产生相应的拖曳滑动。

附录相关文章:

1,《Android自底部平滑向上滑出面板的AndroidSlidingUpPanel》链接地址:http://blog.csdn.net/zhangphil/article/details/51444509

Android音乐、视频类APP常用控件:DraggablePanel(1)的更多相关文章

  1. Android音乐、视频类APP常用控件:DraggablePanel(2)

     Android音乐.视频类APP常用控件:DraggablePanel(2) 附录文章1主要演示了如何使用DraggablePanel 的DraggableView.DraggablePanel ...

  2. Android support library支持包常用控件介绍(二)

    谷歌官方推出Material Design 设计理念已经有段时间了,为支持更方便的实现 Material Design设计效果,官方给出了Android support design library ...

  3. Android support library支持包常用控件介绍(一)

    谷歌官方推出Material Design 设计理念已经有段时间了,为支持更方便的实现Material Design设计效果,官方给出了Android support design library 支 ...

  4. APP常用控件学习理解

    1.TextView 示例: layout_width指的是文本的所占宽度(不一定填充满),layout_height指的是文本所占高(不一定填充满),warp_coonent :包裹文本宽度 mat ...

  5. Android App常用控件

  6. android内部培训视频_第三节 常用控件(Button,TextView,EditText,AutocompleteTextView)

    第三节:常用控件 一.Button 需要掌握的属性: 1.可切换的背景 2.9.png使用 3.按钮点击事件 1)  onClick 3) 匿名类 4) 公共类 二.TextView 常用属性 1.a ...

  7. android内部培训视频_第三节(3)_常用控件(ViewPager、日期时间相关、ListView)

    第三节(2):常用控件之ViewPager.日期时间相关.ListView  一.ViewPager 实例:结合PagerAdapter滑动切换图片  二.日期时间相关:AnalogClock\Dig ...

  8. 五、Android学习第四天补充——Android的常用控件(转)

    (转自:http://wenku.baidu.com/view/af39b3164431b90d6c85c72f.html) 五.Android学习第四天补充——Android的常用控件 熟悉常用的A ...

  9. Android中常用控件及属性

    在之前的博客为大家带来了很多关于Android和jsp的介绍,本篇将为大家带来,关于Andriod中常用控件及属性的使用方法,目的方便大家遗忘时,及时复习参考.好了废话不多讲,现在开始我们本篇内容的介 ...

随机推荐

  1. 看看 SDWebImage内部基本实现过程

    一.实现流程 入口 setImageWithURL:placeholderImage:options: 会先把 placeholderImage 显示,然后 SDWebImageManager 根据 ...

  2. astgo 老版本免激活完整安装包带安装命令脚本

    astgo是个国产的老牌经典软交换服务器,主要用来当回拨网络电话服务端,同时也具备群呼.传真等功能! 这个需要安装在centos 5.x 32位系统.带安装脚本,上传到root目录后执行安装脚本即可等 ...

  3. C++ 指针 部分

    基本知识:在内存中的每个字节都有一个编号,这就是“地址”,相当于旅馆中的房间号.记住,内存单元的地址和内存单元的内容是两个不同的概念. 程序在编译之后,就已经将变量名转换成变量地址,对变量值的存取都是 ...

  4. P3128 [USACO15DEC]最大流Max Flow(LCA+树上差分)

    P3128 [USACO15DEC]最大流Max Flow 题目描述 Farmer John has installed a new system of  pipes to transport mil ...

  5. 【题解】永无乡 [HNOI2012] [BZOJ2733] [P3224]

    [题解]永无乡 [HNOI2012] [BZOJ2733] [P3224] [题目描述] 永无乡包含 \(n\) 座岛,编号从 \(1\) 到 \(n\) ,每座岛都有自己的独一无二的重要度,按照重要 ...

  6. 实战篇之实现 OutLook 中以 EDM 形式发送通知邮件

    1.写 Html5 的 EDM 模板 EDM 源代码示例: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ...

  7. Android内存管理(12)*「实例」用Monitor 生成.hprof文件 并分析内存泄漏

    参考 http://blog.csdn.net/xiaanming/article/details/42396507 基本步骤: 1,准备一个有内存泄漏的代码 2,如何发现内存泄漏 3,生成.hpro ...

  8. React Native 环境搭建踩坑

    React Native (web Android)环境搭建踩坑(真的是一个艰辛的过程,大概所有坑都被我踩了 官方文档地址 : https://facebook.github.io/react-nat ...

  9. ionic中遇到的一些问题和坑

    接触ionic有一段时间了,一路上踩了不少坑.大部分都记录下来了,分享给大家,可以少走很多弯路 1,ng-init不能在body里面初始化,可以在一个段落里面初始化<div ng-init> ...

  10. JS——样式获取的兼容写法

    样式获取 普通获取属性方式div.style.width或者div.style["width"]无法获取内嵌和外链式,只能获取行内式 window.getComputedStyle ...