我在滚动ListView里面遇到麻烦ScrollView.我有一个Activity在顶部有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡都有一个ListView.当EditText视图聚焦时,软键盘出现,因为我有一个ScrollView,内容是可滚动的.但问题出现在ListViews中有更多项目(选项卡中的项目),即使有更多项目,我也无法滚动ListView.
以下是布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?backgroundImage"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_margin="10dip"
android:id="@+id/buttons">
<Button
android:text="Save"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnSaveorUpdate"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
<Button
android:text="Cancel"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnCancelorDelete"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
</LinearLayout>
<ScrollView
android:layout_above="@id/buttons"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_margin="10dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dip">
<TextView
android:text="Bill details"
android:textColor="?textColorDark"
android:layout_alignParentTop="true"
android:id="@+id/txtEnterDetails"
android:textSize="25dip"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="2dip"></TextView>
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0dip"
android:layout_height="0dip" />
<EditText
android:layout_width="fill_parent"
android:hint="Enter data"
android:inputType="numberDecimal"
android:id="@+id/txtSample"
android:textSize="@dimen/editText"
android:layout_height="@dimen/editTextHeight"
android:text=""></EditText>
<EditText
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:hint="Enter description"
android:textSize="@dimen/editText" …Run Code Online (Sandbox Code Playgroud) 我正在使用TableLayout.我需要为此布局同时进行水平和垂直滚动.默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用.
我使用的是Android SDK 1.5 r3.我已经尝试过了android:scrollbars="horizontal".
我在一些论坛上看到,在杯形蛋糕更新中,水平滚动是可能的.
如何让我的布局在两个方向上滚动?
我有一个66个视图的网格,如果一个视图被触摸或拖动/移动我想改变它的背景颜色.
我猜我需要在父ViewGroup上放置一个触摸侦听器,但是如何确定拖动/移动哪个子视图?
我正在尝试将ScrollView放在另一个ScrollView中,我尝试了在这个网站上找到的答案,但它似乎仍然没有完全发挥作用.这是XML:
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewDirectoryDetailName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/red" />
<LinearLayout
android:id="@+id/linearLayoutDirectoryDetailContainImage"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@drawable/general_image"
android:gravity="center"
android:orientation="vertical" >
</LinearLayout>
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:focusableInTouchMode="false" >
<TextView
android:id="@+id/textViewDirectoryDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:autoLink="phone"
android:text="098 123 45 678"
android:textAppearance="?android:attr/textAppearanceLarge" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是Java代码:
parentScrollView = (ScrollView) findViewById(R.id.scrollView1);
childScrollView = (ScrollView) findViewById(R.id.scrollView2);
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View p_v, MotionEvent p_event) {
childScrollView.getParent().requestDisallowInterceptTouchEvent(
false);
// We will have to follow above for all scrollable …Run Code Online (Sandbox Code Playgroud) 我的活动中有以下代码:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="160dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
我想在框架布局("main_content"id布局)中添加一个带有RecyclerView的片段,但在这种情况下,这不起作用.
问题是什么?你知道一些例子吗?
我正在研究创建一个显示EPG数据的视图.那个观点应该是:
除了自己绘制整个视图(在可滚动的内部?)如果有任何好的方法我可以使用涉及线性布局等,我完全难过.
非常感谢任何提示 - 请注意我和android初学者.
我要在垂直列表视图中创建一个水平列表视图.两个列表视图都可以包含任意数量的元素,并且两者都需要可滚动.
我将如何实现这一点,因为我已经读过android不支持列表视图层次结构.
谢谢 !

当编辑文本获得焦点后出现软键盘时,我试图调整布局。现在,如果我有很多编辑文本并且键盘出现,则最后一个编辑文本被隐藏并且我无法向上滚动。
这是我的布局是如何构建的:
模板:
<LinearLayout>
<LinearLayout>
// header 1
</LinearLayout>
<LinearLayout>
// header 1
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical">
// where I inflate view_1
</LinearLayout>
<LinearLayout>
// footer
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
视图 (view_1):
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout>
// ...
</LinearLayout>
<LinearLayout>
// ...
</LinearLayout>
<LinearLayout>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
<TextView/>
<EditText/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了android:windowSoftInputMode(在 manifest.xml 上和以编程方式)的各种组合。我试图设置android:isScrollContainer="false"滚动视图,但没有。
我也试过这个答案,在我的滚动视图中放置了一个 GlobalLayoutListener ,但是当键盘出现时没有调用 onGlobalLayout 。而且isKeyboardShown总是假的。
我有一个棘手的问题,涉及两个不同视图的同步滚动.我已经创建了自己的自定义网格视图窗口小部件,左侧和顶部都有"粘性"视图,只有在网格的一个方向上.想想一个日历,你有时间在顶部,日期在左边,当你水平滚动时间时,日期视图应保持不变,当你垂直滚动日期时,时间视图应保持不变.
网格本身是使用垂直滚动视图中的嵌套水平滚动视图实现的.电网运行良好,所以没问题.由于粘性视图不在实际网格中,因此我在网格滚动视图中覆盖了onScrollChanged,并在用户滚动网格时以编程方式调用粘贴视图上的scrollTo.
这可以按预期工作,除了两个不同的视图开始滚动和结束滚动时有一个小的时间偏移.当您考虑滚动可能是在UI线程上线性执行时,我认为这是有道理的.
所有的视图都是滚动视图,我已经启用了平滑滚动和使用smoothScrollTo等,而不是尝试改进这一点,但它仍然是同样的问题.这个问题在较大的屏幕上尤为明显,例如三星Galaxy Tab,而在中小屏幕设备上则难以察觉.
任何帮助表示赞赏!如果有一个简单的解决方案,很好..如果它意味着新设计(满足上面的粘性视图用例),那么就这样吧.
用于触发编程的代码.滚动,水平相同
@Override
protected void onScrollChanged(int x, int y, int oldx, int oldy) {
mListener.onScrollY(y);
super.onScrollChanged(x, y, oldx, oldy);
}
// which leads to,
// Handle vertical scroll
public void onScrollY(final int y) {
mCurrentY = y;
mVerticalScroll.smoothScrollTo(0, y);
}
Run Code Online (Sandbox Code Playgroud)
下面是XML布局,如果有任何帮助的话
实际网格,它是一个包含在垂直滚动视图中的水平滚动视图,网格项在嵌套的linearlayout中垂直添加
>
< com.....VerticalScrollView
android:id="@+id/gridscroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/timescroll"
android:layout_toRightOf="@id/vertscroll"
android:layout_alignTop="@id/vertscroll"
android:layout_marginLeft="2dp" android:scrollbars="none"
android:fadingEdge="none">
< com....HorizScrollView
android:id="@+id/horizscroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:fadingEdge="none">
< LinearLayout android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
< /LinearLayout>
< /com.....HorizScrollView>
< /com.....VerticalScrollView>
Run Code Online (Sandbox Code Playgroud)
水平粘滞视图
< …Run Code Online (Sandbox Code Playgroud) 我有一个ScrollView包含LinearLayout各种元素的复合体,其中有几个TextView定义了maxHeight ,里面有一个长文本.我需要在内部TextView触摸和拖动时滚动文本,以及在ScrollView它们之外触摸和拖动时的正常滚动.
是否有一种适当而优雅的方式来做到这一点 - 如果可能的话 - 或者我是否必须弄脏并开始覆盖所onTouchEvent涉及的所有元素的处理程序?
UPD 1:从这一点来看,没有优雅的解决方案,并且必须重新考虑UI以仅包括一层可滚动元素.
这是我的布局xml.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/garae_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:fillViewport="true"
android:focusableInTouchMode="false" >
<RelativeLayout>
...
<com.handmark.pulltorefresh.library.PullToRefreshScrollView>
<LinearLayout/>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
我已经在这个链接中尝试了解决方案: ScrollView Inside ScrollView
但是,它没有用.如何使用子PullToRefreshScrollView?请帮我.
我遇到了一个问题,我不确定解决它的最佳方法。我需要在滚动视图中包含所有小部件。
下面是布局,我使用了框架布局,因为我需要重叠一堆图像。然而,整个框架布局不能在滚动视图内。但我需要滚动整个面板。用黄色箭头标记的部分显示了框架布局。
我看了这个帖子,但这不是我想要的。
这是xml,如果有人可以提供线索,我将不胜感激。谢谢!
<!-- unfortunately I cannot put this inside the scrollview :( -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_background"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/follow_add" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:gravity="center|bottom"
android:orientation="horizontal">
<ImageView
android:id="@+id/image_icon"
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@drawable/feed_active" />
</LinearLayout>
<ImageView
android:id="@+id/dismiss"
android:layout_gravity="left"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/close_messages_modal" />
<ImageView
android:id="@+id/follow"
android:layout_gravity="right"
android:layout_margin="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/follow_add" />
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="Layout above needs to scroll"
android:textColor="@color/half_dark_text_color"
android:textSize="28sp"
android:textStyle="bold" /> …Run Code Online (Sandbox Code Playgroud) android ×12
scrollview ×6
listview ×2
custom-view ×1
gridview ×1
layout ×1
pull ×1
refresh ×1
scroll ×1
textview ×1
touch-event ×1
view ×1