如何使linearLayout滚动而不将其放在scrollview中

时间:2017-07-26 07:32:02

标签: scrollview android-linearlayout

我有linearlayout包含

textView
imageView
Horizontal recyclerview
TextView
Horizontal Recyclerview
Webview

如何在不将scrollable放入scrollview的情况下将其设为image: node:wheezy cache: paths: - node_modules/ stages: - build - test gem_lint: image: ruby:latest stage: build script: - gem install scss_lint artifacts: paths: - node_modules/ only: - dev except: - master install_dependencies: stage: build script: - npm install artifacts: paths: - node_modules/ only: - dev except: - master scss-lint: stage: test script: - npm run lint:scss-lint artifacts: paths: - node_modules/ only: - dev except: - master

3 个答案:

答案 0 :(得分:0)

在不使用Scrollview

的情况下使Linearlayout可滚动

如果您只在线性布局中使用列表视图,那么您不需要使用scrollview.Because默认情况下ListView是可滚动的。但是如果您还有其他组件,那么您可以将其他组件分开。确保ScrollView仅使用一个直接子布局。以下是示例代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  android:background="#ffffff"> 

   <ListView

    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="#b5b5b5"
    android:dividerHeight="1dp"
    android:cacheColorHint="#00000000"/> 

</LinearLayout>

答案 1 :(得分:0)

你不能。线性布局的设计不允许其内容可滚动 - 只有将其嵌入到FrameLayout(或ScrollView,它是子类)中才能滚动/平移。为什么ScrollView不是一个选项?

顺便说一句,垂直滚动容器内的水平滚动容器不能提供良好的UI / UX,但还有其他方法可以实现您所追求的目标。请提供更多详细信息,我们确信我们能够为您提供帮助

答案 2 :(得分:0)

根据Android开发者网站的说法,建议不要在ScrollView中安装RecyclerView / ListView。

  

永远不要将RecyclerView或ListView添加到滚动视图。这样做   导致用户界面性能不佳和用户体验不佳。

供参考 https://developer.android.com/reference/android/widget/ScrollView

另外,建议使用NestedScrollView。