我有更多数据的列表视图[文本视图和复选框控件].我将从列表视图中选择项目,并在下一个活动中显示所选项目.我的问题是,例如,如果我在列表视图中选择第20和第25项,它将在下一个活动中显示其他一些项目.即列表视图位置在滚动时会发生变化.
我通过单击项目上的复选框选择项目.在checkbox.setOnChanged监听器中,我编写了代码选择与否的代码.如果我选择第25个项目并滚动列表视图,则调用getview方法,并且checkbox.setonChanged方法将更改所选位置. 我最后打印了logcat.
我的编码格式:
public class ListContact extends ListActivity {
public void onCreate(Bundle icicle){
.....
ArrayAdapter<Model> adapter = new MyCustomArrayAdapter(this,getModel());
setListAdapter(adapter);
}
....
private List<Model> getModel() {
List<Model> list = new ArrayList<Model>();
Iterator<String> itr = constant.selectname.iterator();
while (itr.hasNext()) {
list.add(get(itr.next().toString()));
}
return list;
}
private Model get(String s) {
return new Model(s);
}
}
Run Code Online (Sandbox Code Playgroud)
MyCustomArrayAdapter.java:
public class MyCustomArrayAdapter extends ArrayAdapter<Model> {
private final List<Model> list;
private final Activity context;
constant con ;
public MyCustomArrayAdapter(Activity context, List<Model> list) {
super(context, …Run Code Online (Sandbox Code Playgroud) 我正在尝试重现两个版本的Google I/O 2014应用程序的效果,第一个在滚动时淡出的版本,以及在靠近工具栏时伸展的更新版本

我下载了应用程序的源代码,但这种影响不在公共资源上,所以我试图找出如何通过自我实现
我已经做的是创建一个自定义视图,它将translationY从actionbarHeight设置为0,反之亦然,但它看起来不是最好的方法,有没有人知道更好的方法?
android android-animation googleio android-scroll android-toolbar
我正在使用新设计库开发Android应用程序.我想创建一个类似的滚动效果,用于新的Google相册应用.我希望AppBarLayout完全滚出屏幕,以便回收器视图在状态栏后面滚动.
我在应用程序的主题中将windowTranslucentStatus设置为true.这是主要活动的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是滚动下来时的样子:

工具栏不会完全消失.
感谢帮助!
android android-scroll google-photos material-design android-toolbar
我正在尝试检查某些特定项目是否可见RecyclerView; 但我无法实现这一点.请帮我确定我的物品是否完全可见RecyclerView.
mrecylerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayout ll = (LinearLayout) recyclerView.findChildViewUnder(dx, dy);
if (ll != null) {
TextureVideoView tvv = (TextureVideoView) ll.findViewById(R.id.cropTextureView);
}
}
});
Run Code Online (Sandbox Code Playgroud)
我想检查tvv视图是否在视图中完全可见mrecyclerView.
我正在考虑在我的项目中添加过度滚动(而不是颜色变化),但即使在阅读了API文档和这里的几个问题后,我仍然不明白我需要做些什么才能使它工作.
根据OverScroller的API文档:" 这个类封装了滚动,能够超越滚动操作的范围.在大多数情况下,这个类是Scroller的直接替代品. "
我之前在父类中有一个Scroller对象:
public boolean onTouchEvent(MotionEvent ev) {
....// code to calculate deltas
if (deltaY != 0 || deltaX != 0)
scrollBy(deltaX, deltaY);
}
Run Code Online (Sandbox Code Playgroud)
然后我去改变它:
if (deltaY != 0 || deltaX != 0)
overScrollBy(deltaX, deltaY, getScrollX(), getScrollY(),
child.getRight() - getWidth(), child.getBottom() - getHeight(),
OVERSCROLL_DISTANCE, OVERSCROLL_DISTANCE, false);
Run Code Online (Sandbox Code Playgroud)
现在滚动根本不起作用!fling()作为一个替代滴,但不滚动....
总之,我有两个问题:
overScrollBy?我是否必须添加其他代码才能使其正常工作?mScroller.fling(),只overScrollBy()?为什么不mScroller.overScrollBy()呢?它是否以某种方式构建在View课堂上?这可能是非常明显的,但我在这里挣扎.任何帮助将非常感谢,谢谢!
我有一个带有可扩展子视图的RecyclerView,当单击子ViewGroup时,它会将ViewGroup高度从0调整为测量视图组高度的视图数量膨胀,如下面的gif所示:

问题是:我在recyclerView上调用smoothScrollToPosition,它平滑滚动到视图位置,但是在上面的gif中我认为当前的视图高度仍然没有展开,我正在回收在recyclerview的视图下面,由于视图已经可见,因此不会滚动到位置,但是当我再次触摸(再次调用smoothscrolltoposition)时,它会将视图滚动到正确的位置,因为视图已经展开.
有没有办法将视图滚动到屏幕顶部或只是滚动以使内容可见?
对于引用:这是调用以扩展视图的方法:
collapsible_content.removeAllViews();
for(int i = 0; i < 5; i++) {
View link_view = getLayoutInflater().inflate(R.layout.list_item_timeline_step_link, collapsible_content, false);
TextView text = (TextView) link_view.findViewById(R.id.step_link_text);
text.setText("Test");
collapsible_content.addView(link_view);
}
Run Code Online (Sandbox Code Playgroud)
这是我扩展的方法:
public void toggle() {
collapsible_content.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Animation a;
if (mExpanded) {
a = new ExpandAnimation(collapsible_content.getLayoutParams().height, 0);
} else {
a = new ExpandAnimation(collapsible_content.getLayoutParams().height, getMeasuredHeight());
}
a.setDuration(mAnimationDuration);
collapsible_content.startAnimation(a);
mExpanded = !mExpanded;
}
Run Code Online (Sandbox Code Playgroud)
和动画:
private class ExpandAnimation extends Animation {
private final int mStartHeight;
private final int mDeltaHeight;
public ExpandAnimation(int startHeight, int endHeight) …Run Code Online (Sandbox Code Playgroud) java android android-animation android-scroll android-recyclerview
我有一个明显可滚动的列表视图.列表视图包含一些表单问题.一旦用户提交表单,我们就会在列表视图的顶部放置一个类似邮票的自定义视图(并阻止用户回答问题,但这并不重要).
图章应显示在列表视图的顶部(如屏幕顶部),并且可以与列表视图相同的速度滚动,即当最初位于其下方的列表视图项目消失在屏幕顶部时,它应该消失.滚动.
知道怎么做到这一点?
如何使数字选择器滚动/速度更快?目前从00分钟到59分钟需要付出很多努力.我已经尝试了一些示例来自Android中Viewpager控制器的减速速度,并将其应用于数字选择器,但我没有看到任何差异.
try {
Field mScroller;
mScroller = NumberPicker.class.getDeclaredField("mFlingScroller");
mScroller.setAccessible(true);
FixedSpeedScroller scroller = new FixedSpeedScroller(getContext(),null,true);
// scroller.setFixedDuration(5000);
// scrollBy(0,1500);
Log.v("Scroller",""+mScroller); //getting the mFlingScroller field
mScroller.set(this, scroller);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
public class FixedSpeedScroller extends Scroller {
private int mDuration = 10;
public FixedSpeedScroller(Context context) {
super(context);
}
public FixedSpeedScroller(Context context, Interpolator interpolator) {
super(context, interpolator);
}
public FixedSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
super(context, interpolator, flywheel);
}
@Override
public void startScroll(int …Run Code Online (Sandbox Code Playgroud) 我使用以下用户界面:
parentLayout尺寸为800x600(宽x高)的父相对布局
第二个相对布局childLayout,它是父布局的子级.它的尺寸为800x1000,即它大于父布局.
parentLayout.addView(childLayout);
Run Code Online (Sandbox Code Playgroud)我的目标:childLayout使用滚动childLayout.scrollTo(x,y).
当我使用时childLayout.scrollTo(x,y),Android滚动childLayout但不刷新(重绘)它.效果是,childLayout切割成相同的尺寸parentLayout.
不幸的是,以下解决方案无法解决问题:
childLayout.scrollTo(x,y);
childLayout.invalidate();
childLayout.requestLayout();
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这个问题?
我需要将两个ViewPager同步在一起.要求类似于滚动ViewPager-1,ViewPager-2也应该滚动一定量.下面的图片将使您更清楚我的问题.
你也可以帮我一些教程链接.谢谢.
android android-layout android-scrollview android-viewpager android-scroll