我在ViewFlipper中有一个垂直的ScrollView(实际上是一个自定义的ScrollView,代码如下).除非我在ScrollView上水平滑动以翻转到上一个/下一个视图,否则ViewFlipper工作正常.ScrollView本身可以正常工作.
这是设计.绿色框是ScrollView,它应该是垂直的.

这是ScrollView:
public class SCScrollView extends ScrollView {
private float xDistance, yDistance, lastX, lastY;
GestureDetector gestureDetector = new GestureDetector(new MyGestureDetector());
OnTouchListener gestureListener;
public SCScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
gestureListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
};
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
xDistance = yDistance = 0f;
lastX = ev.getX();
lastY = ev.getY();
break;
case MotionEvent.ACTION_MOVE: …Run Code Online (Sandbox Code Playgroud) ViewPager我的活动中有一个。我Fragment用来显示清单ViewPager。在ViewPager我可以设置一个ListView。ListView可以正确显示,但ListView不能滚动。因此列表中的几项无法显示。
我该怎么解决。
主要活动
public class MainActivity extends Activity {
private PageAdapter mSectionsPagerAdapter;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new PageAdapter(getSupportFragmentManager(), 3);
// Set up the ViewPager with the sections …Run Code Online (Sandbox Code Playgroud) 我有像播放商店应用程序的要求,其中有视图寻呼机与图像和视频,并滚动查看详细信息.不幸的是,当用户滚动滚动是跳跃但但如果我删除滚动视图,视图寻呼机工作完全正常.
布局外观就像这样 http://cl.ly/MBRB
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:fillViewport="true">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="160dp"
android:background="@drawable/loading_image"
android:gravity="top"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/product_image_pager"
android:layout_width="fill_parent"
android:layout_height="match_parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/titles"
style="@style/CirclePageIndicator"
android:layout_alignParentBottom="true"
android:padding="10dip"
android:paddingBottom="10dp" />
</RelativeLayout>
<include layout="@layout/app_screen_menu" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我正在从服务器加载图像.
谢谢
我有嵌套日历视图ScrollView.当视图高度增加时,我的问题就开始了.我可以垂直滚动日历月,但当scrollview滚动条出现时,它不会滚动日历.整个视图向上或向下滚动而不是滚动日历.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout android:orientation="vertical" android:id="@+id/ReminderLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/TaskName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:singleLine="true"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes" />
<EditText
android:id="@+id/TaskNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblReminder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reminder" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">"
<CalendarView
android:id="@+id/calendarReminder"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:scrollbars="vertical"
android:isScrollContainer="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TimePicker …Run Code Online (Sandbox Code Playgroud) 我有一个自定义内部的布局,ViewPager不会垂直滚动.自定义ScrollView用于修复使用ScrollView滑动的可怕选项卡.ViewPagerScrollView
是的,有足够的内容可以滚动,我尝试使用和不使用底部按钮.
我正在使用具有3个选项卡的ActionBar,当前代码允许向左/向右滑动就好了.
我的目标是为一些动作项目设置底部栏,例如保存和取消,以及ActionBar和底部按钮之间的部分是将垂直滚动的ViewPager.
我尝试过太多组合,现在正在给你寄这封情书.有任何想法吗?如有需要,欢迎任何帮助,并随时询问其他详细信息.
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"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/footer"
style="@android:style/Holo.ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
<com.blah.hootiehoo.ViewPagerCompatScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/footer"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</com.blah.hootiehoo.ViewPagerCompatScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
ViewPager mViewPager;
TabsAdapter mTabsAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); …Run Code Online (Sandbox Code Playgroud) 我知道在ScrollView中有很多关于ViewPager情况的问题,但是我还没有看到一个描述我所面临的情况的问题.
问题是,当我没有ScrollView时,我的viewPager工作正常,因为它可以在这张照片中看到.

如果我将ScrollView仅用于ViewPager下面的元素,我也会工作,但我不想要这种行为.

当我添加ScrollView时,我可以向上和向下滚动,我也可以向左和向右滑动(为此,我使用这种方法),但随后图像被加载但未显示,因为它可以在下面的图片中看到.

我发现如果,例如,我有四个图像,我在第一个位置看到第一个图像,我可以向右滑动两次(第三个位置),我什么也看不到,但是当我滑动时一次回到左边(第二个位置),我可以看到第二个图像!
不完全确定它是否相关,但方法getCount似乎完全疯了并且不断被称为不停.
XML
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/footer"
android:id="@+id/custom_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarFadeDuration="0"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.-----.-----.WrapContentHeightViewPager
android:id="@+id/imagePager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title"
android:textSize="15sp"
android:paddingTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<TextView
android:id="@+id/tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tags"
android:textColor="#ffff44"
android:textSize="13sp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同类型的自定义ScrollViews,但问题仍然存在.我正在使用Android 4.4的Nexus 4进行测试