资源简介
安卓的本地音乐播放器 可显示歌词,界面的切换使用了动画效果,稍作修改可实现网易云的转盘效果
代码片段和文件信息
package com.jiang.cn;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.Scroller;
/**
* 自定义View,模仿android 桌面Luncher
*/
public class BigDragableLuncher extends ViewGroup {
// 按钮背景色
int choseColor defaultColor;
// 底部按钮数组
ImageButton[] bottomBar;
// 负责得到滚动属性的对象
private Scroller mScroller;
// 滚动的起始X坐标
private int mScrollX = 0;
// 默认显示第几屏
private int mCurrentScreen = 0;
public int mTouchSlop = 0;
public BigDragableLuncher(Context context) {
super(context);
mScroller = new Scroller(context);
// 得到状态位
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
//设置布局参数
this.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT
ViewGroup.LayoutParams.FILL_PARENT));
}
public BigDragableLuncher(Context context AttributeSet attrs) {
super(context attrs);
mScroller = new Scroller(context);
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
//设置布局参数
this.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT
ViewGroup.LayoutParams.FILL_PARENT));
TypedArray a = getContext().obtainstyledAttributes(attrs
R.styleable.DragableLuncher);
mCurrentScreen = a.getInteger(
R.styleable.DragableLuncher_default_screen 0);
}
//设置底部按钮颜色
public void setBottomBarBg(ImageButton[] ib int choseColor
int defaultColor) {
this.bottomBar = ib;
this.choseColor = choseColor;
this.defaultColor = defaultColor;
}
//屏幕滚动
public void snapToDestination() {
final int screenWidth = getWidth();
//滑动距离超过1/2屏幕时,进入下一个界面
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
snapToScreen(whichScreen);
}
/**
* 带动画效果显示界面
*/
public void snapToScreen(int whichScreen) {
mCurrentScreen = whichScreen;
final int newX = whichScreen * getWidth();
final int delta = newX - mScrollX;
mScroller.startScroll(mScrollX 0 delta 0 Math.abs(delta) * 2);
invalidate();
}
/**
* 不带动画效果显示界面
*/
public void setToScreen(int whichScreen) {
mCurrentScreen = whichScreen;
final int newX = whichScreen * getWidth();
mScroller.startScroll(newX 0 0 0 10);
invalidate();
}
//取得当前屏幕位置
public int getCurrentScreen() {
return mCurrentScreen;
}
//改变布局时调用
@Override
protected void onLayout(boolean changed int l int t int r int b) {
int childLeft = 0;
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
//从左到右依次排列子元素
if (child.getVisibility() != View.GONE) {
final int childWidth = child.getMeasuredWidth();
child.layout(childLeft 0 childLeft + childWidth
child.getMeasuredHeight());
childLeft += ch
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 352 2018-06-28 13:07 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 13:11 MyMusicPla
文件 54708 2018-06-28 12:23 MyMusicPla
文件 232 2018-06-28 13:11 MyMusicPla
文件 5296 2018-06-28 12:23 MyMusicPla
文件 2260 2018-06-28 12:23 MyMusicPla
文件 1274 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 13:15 MyMusicPla
文件 592 2018-06-28 13:15 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
文件 1430 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 13:59 MyMusicPla
文件 4310 2018-06-28 12:23 MyMusicPla
文件 14793 2018-06-28 12:23 MyMusicPla
文件 8824 2018-06-28 12:23 MyMusicPla
文件 617 2018-06-28 12:23 MyMusicPla
文件 3194 2018-06-28 12:23 MyMusicPla
文件 3668 2018-06-28 13:21 MyMusicPla
文件 597 2018-06-28 12:23 MyMusicPla
文件 25247 2018-06-28 13:59 MyMusicPla
文件 2749 2018-06-28 12:23 MyMusicPla
文件 7375 2018-06-28 13:59 MyMusicPla
文件 1592 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
目录 0 2018-06-28 12:23 MyMusicPla
文件 280 2018-06-28 12:23 MyMusicPla
............此处省略87个文件信息
相关资源
- 安卓记账本.zip
- NFC读卡信息小源码.zip
- 修改后的健康食谱安卓源码
- 便签-小米安卓源码
- 数独游戏安卓源码
- 房贷计算器 安卓源码
- 安卓源码音乐播放器,有播放和下一
- 飞翔的小鸟安卓源码,完美运行,横
- nrf51822蓝牙连接APP安卓源码
- 安卓源码BTClient客户
- pluse sensor心率传感器安卓源码
- 打地鼠,安卓源码小游戏
- 7个安卓源码小程序很适合初学者
- 安卓截屏小工具源码
- 安卓源码Eclipse
- 秒钟计时器小应用源码.zip
- 安卓家庭用药助手源码.zip
- 炫酷计时器功能源码.zip
- 音乐播放器源码.zip
- 宾馆管理系统应用源码.zip
- 安卓教务管理系统
- 2048安卓源码小游戏
- 通讯录安卓源码,可以添加联系人和
- FlappyBird安卓源码
- 汉诺塔安卓源码
评论
共有 条评论