谁有Android 滚轮滑动选择日期的源代码
答案:2 悬赏:20 手机版
解决时间 2021-01-27 13:12
- 提问者网友:酱爆肉
- 2021-01-26 15:13
谁有Android 滚轮滑动选择日期的源代码
最佳答案
- 五星知识达人网友:等灯
- 2021-01-26 16:25
很多APP都有这个功能 我是iOS程序员所以只能和你说实现方法,安卓也是类似的
实现这种滚动方式肯定是scrollView无疑,然后让某个位置的view正面朝向,把它当做当前选中的卡牌,它左右的卡牌倾斜放置。如果想要流畅滚动,复用是一定的,自己摸索吧
实现这种滚动方式肯定是scrollView无疑,然后让某个位置的view正面朝向,把它当做当前选中的卡牌,它左右的卡牌倾斜放置。如果想要流畅滚动,复用是一定的,自己摸索吧
全部回答
- 1楼网友:污到你湿
- 2021-01-26 17:02
package com.googlecode.android.widgets.DateSlider;
import java.util.Calendar;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
public class SliderContainer extends LinearLayout {
private Calendar mTime = null;
private OnTimeChangeListener mOnTimeChangeListener;
private int minuteInterval;
public SliderContainer(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(VERTICAL);
}
@Override
protected void onFinishInflate() {
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
if (v instanceof ScrollLayout) {
final ScrollLayout sl = (ScrollLayout)v;
sl.setOnScrollListener(
new ScrollLayout.OnScrollListener() {
public void onScroll(long x) {
mTime.setTimeInMillis(x);
arrangeScrollers(sl);
}
});
}
}
}
public void setTime(Calendar calendar) {
mTime = Calendar.getInstance(calendar.getTimeZone());
mTime.setTimeInMillis(calendar.getTimeInMillis());
arrangeScrollers(null);
}
public Calendar getTime() {
return mTime;
}
public void setMinTime(Calendar c) {
if (mTime==null) {
throw new RuntimeException("You have to call setTime before setting a MinimumTime!");
}
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View v = getChildAt(i);
if (v instanceof ScrollLayout) {
ScrollLayout scroller = (ScrollLayout)v;
scroller.setMinTime(c.getTimeInMillis());
}
}
}
public void setMaxTime(Calendar c) {
if (mTime==null) {
throw new RuntimeException("You have to call setTime before setting a MinimumTime
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯