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. P3258 [JLOI2014]松鼠的新家 树链剖分

    这个题就是一道树剖板子题,就是每走一步就把所有的经过点加一就行了.还有,我的树剖板子没问题!!!谁知道为什么板子T3个点!我不管了!反正这道题正常写A了. 题干: 题目描述 松鼠的新家是一棵树,前几天 ...

  2. SEL是啥玩意

    一.了解SEL前的准备-----isa指针简述 1.一个类就像一个 C 结构,NSObject 声明了一个成员变量: isa.由于 NSObject 是所有类的根类,所以所有的对象都会有一个 isa ...

  3. PCB MS SQL 标量函数(CLR) 实现DataTable转HTML的方法

    一.准备需转为HMLT字符串的DataTable数据 在数据库中执行一段SQL返回的数据 需转换后的HTML的文本 <html ><head></head>< ...

  4. SpringBoot SpringDataJPA 动态查询、多条件查询

    Spring-data - JPA用的还是比较多的,之前在公司也一直在用,因为方便.下面我们来整理一下如何配置. pom.xml <?xml version="1.0" en ...

  5. 《Typecript 入门教程》 2、访问控制符:public、private、protected、readonly

    声明类的属性和方法时可以设置使用访问控制符,访问控制符设置类的属性和方法能不能在类的外部被访问 1. 默认为 public,使用public定义的属性和方法在类的内部和外部都可以访问 2. priva ...

  6. 【Leetcode 86】 Partition List

    问题描述: 给定一个list, 将所有小于x的node放到左边,剩下的保持原样. 问题解决: 闲的无聊,用c++和python都做了一遍. 代码如下: # Definition for singly- ...

  7. SQL SERVER中存储过程IN 参数条件的使用!!!

    正常的传递  @SendStationID='''1'',''2''' 是无效,改用 @SendStationID='1,2,3,003,002' 调用以下的存储过程可以实现in 查询效果 USE [ ...

  8. xcode常用的快捷键

    按键 描述 command+[ 左移代码块 command+] 右移代码块 Tab键 接受代码自动完成提示 Esc键 显示代码提示菜单 command+方向left键 移动光标到本行行首 comman ...

  9. canvas烟花锦集

    canvas可以实现不同动画效果,本文主要记录几种不同节日烟花效果实现. 实现一 效果地址 html <canvas id="canvas"></canvas&g ...

  10. js基础---元素操作时字符串拼接

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...