android-scrollview 相关问题

一个Android小部件,如果它对于屏幕的可见区域太大,则允许滚动其唯一的子节点。

Android 键盘隐藏 EditText

当我尝试在屏幕底部的 EditText 中写入内容时,软键盘会隐藏 EditText。我该如何解决这个问题?下面是我的 xml 代码。我在 Frag 中使用这个...

回答 12 投票 0

Expo Android 滚动故障

我在 Android 上使用我的 expo 应用程序时遇到了一个恼人的故障。当我使用 ScrollView 并将 overScrollMode 设置为“始终”或“自动”并且在开始时滚动得有点快时,我可以到达更远的地方,然后...

回答 1 投票 0

Scrollview:检查视图在屏幕上是否可见

我有一个 ScrollView 定义如下: 我有一个 ScrollView 定义如下: <ScrollView ... .../> <LinearLayout ... ...> <!-- content --> </LinearLayout> </ScrollView> 我用一些 ImageView 动态填充 LinearLayout。现在,有没有办法检查 ImageView 何时变得可见或不可见(例如当我向下滚动时)? 要检查视图是否完全/部分可见,您可以使用: boolean isViewVisible = view.isShown(); 要确定它是否完全可见,请使用以下方法: Rect rect = new Rect(); if(view.getGlobalVisibleRect(rect) && view.getHeight() == rect.height() && view.getWidth() == rect.width() ) { // view is fully visible on screen } 我会转发给你这个答案: 如果图像是布局的一部分,它可能是“View.VISIBLE”,但这并不意味着它在可见屏幕的范围内。如果这就是你所追求的;这会起作用: Rect scrollBounds = new Rect(); scrollView.getHitRect(scrollBounds); if (imageView.getLocalVisibleRect(scrollBounds)) { // imageView is within the visible window } else { // imageView is not within the visible window } 我花了很多功夫才得到准确的答案,以下解决了我的问题 final ScrollView scrollView = findViewById(R.id.scrollView); scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { Rect scrollBounds = new Rect(); scrollView.getHitRect(scrollBounds); if (yourImageView.getLocalVisibleRect(scrollBounds)) { // The ImageView is Visible on the screen while scrolling } else { // The ImageView is not Visible on the screen while scrolling } } }); OnScrollChangedListener 中的代码不断检查 Imageview 是否可见并显示在屏幕上,一旦滚动并且 imageview 不可见,它就会立即被检测到 我为此编写了 Kotlin 扩展函数: fun View.isViewFullyVisible(): Boolean { val localVisibleRect = Rect() getLocalVisibleRect(localVisibleRect) return localVisibleRect.top == 0 && localVisibleRect.bottom == height }

回答 4 投票 0

使用 PdfDocument 从滚动视图生成的 Pdf 仅打印第一页的内容,将其他页面保留为空白

我想通过滚动scrollView的内容来使用Android的PdfDocument类生成pdf文档。 现在,正在生成正确的页数,但内容打印在...

回答 1 投票 0

有没有办法去除ScrollView中屏幕顶部和图像顶部之间的空间?

我想显示我的超高图像,所以我尝试将其放入ScrollView中,并将其限制在屏幕顶部,以便可以滚动它。我想象它会填补

回答 1 投票 0

如何让我的布局水平和垂直滚动?

我正在使用TableLayout。我需要对此布局进行水平和垂直滚动。默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用。 ...

回答 8 投票 0

无法向 ScrollView 添加页脚 - Android

我目前正在开发移动应用程序,当我尝试将页脚放在 ScrollView 下时遇到问题。 这是我的代码: 我目前正在开发移动应用程序,当我尝试将页脚放在 ScrollView 下时遇到问题。 这是我的代码: <RelativeLayout android:id="@+id/RelativeLayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:layout_alignParentBottom="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/bottomcontent" android:orientation="vertical" android:background="@drawable/border"> //the footer is added dynamically </RelativeLayout> <ScrollView android:layout_weight="1" android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/contentcontainer"> <LinearLayout android:id="@+id/scrollcontentcontainer" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> //the content is added dynamically from a layout template </LinearLayout> </LinearLayout> </ScrollView> </RelativeLayout> ScrollView的内容是一组相对布局,里面有一些按钮和文本视图。它基于我多次膨胀的布局。 页脚只是一个 LinearLayout,其中也有一些按钮。 问题是我尝试了在互联网上找到的所有不同的解决方案,但没有一个有效。就我而言,页脚卡在 ScrollView 的内容下方,而不是 ScrollView 本身下方,因此我必须向下滚动,直到内容结束才能到达页脚。但页脚应该保留在屏幕底部...... 我也尝试了这些解决方案,但没有任何效果: http://www.javacodegeeks.com/2013/10/android-fixed-header-and-footer-with-scrollable-content-layout-example.html (当我尝试这个时,我在屏幕顶部有一个页脚,没有其他东西......) http://www.byteslounge.com/tutorials/android-fixed-header-and-footer-with-scrollable-content-layout-example 和其他一些(也不起作用!) 我也尝试了所有可能的东西,比如使用重力、重量、fillViewPort、对齐到底部......但不可能得到预期的结果。 最小API设置为14,我使用Android Studio。 编辑1: 可绘制边框: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:bottom="-2dp" android:left="-2dp" android:right="-2dp" android:top="2dp"> <shape android:shape="rectangle" > <stroke android:width="1dp" android:color="#000000" /> <solid android:color="#3b010101" /> <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp" /> </shape> </item> </layer-list> 您可以尝试以下方法,我在 ScrollView 中添加 RelaveLayout 时也遇到了麻烦。 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/bottomcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@drawable/border"> <!---add something there eg:--> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Test"/> </RelativeLayout> <ScrollView android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@id/bottomcontent" android:layout_alignParentTop="true"> <LinearLayout android:id="@+id/contentcontainer" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:id="@+id/scrollcontentcontainer" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> </LinearLayout> </LinearLayout> </ScrollView> </RelativeLayout> . 我在本文档中找到了以下内容。这肯定会导致问题 注意:在平台版本 17 及更低版本中,RelativeLayout 受到 一个测量错误,可能会导致子视图被测量 MeasureSpec 值不正确。 (参见MeasureSpec.makeMeasureSpec 更多详细信息。)当relativelayout容器被 放置在滚动容器中,例如 ScrollView 或 水平滚动视图。如果自定义视图未正确配备 使用 MeasureSpec 模式进行测量 UNSPECIFIED 被放置在 relativelayout,无论如何,这都会像relativelayout一样默默地工作 将传递一个非常大的 AT_MOST MeasureSpec 相反。 此行为已为设置的应用程序保留 android:targetSdkVersion="17" 或更旧的清单的使用-sdk 兼容性标记。面向 SDK 版本 18 或更高版本的应用程序将 接受正确的行为

回答 1 投票 0

如何在Android中以编程方式将ScrollView滚动到底部?

如何在Android中以编程方式将ScrollView滚动到底部? 提议的代码 logScroll.scrollTo(0, logScroll.getBottom()); 不起作用(滚动到底部,而不是开始时的位置...

回答 2 投票 0

扩展 SwitchMaterial 和 NPE 发生

我正在尝试在Android中自定义SwitchMaterial类,就像这样 类 TipSwitchMaterial @JvmOverloads 构造函数( 上下文:上下文, attrs:属性集? = 空, defStyleAttr: Int =

回答 2 投票 0

使用滚动视图滚动时将子视图固定在屏幕顶部

当视图滚动到顶部时,我需要将视图固定在屏幕顶部。当它到达顶部时,视图应作为标题保留在那里,而下面的其余视图应按正常滚动......

回答 1 投票 0

使用 Android 的 OverScroller 类的最小工作示例?

我试图了解如何在Android中使用OverScroller类来实现平滑滚动。虽然文档提供了概述,但我在拼凑出一个最小的工作示例时遇到了困难

回答 1 投票 0

HorizontalScrollView 不滚动

我想制作一个表格,左侧有实心列,右侧有可水平滚动的可滚动列。 我将其分为两种不同的表格布局,并将正确的一个放在

回答 1 投票 0

滚动到布局底部

我正在尝试滚动到布局底部。我有这段代码,但它不起作用 ScrollViewscrollView = view.FindViewById(Resource.Id.scrollViewHelper); ...

回答 2 投票 0

运行项目后组件被移动

我有两个问题: 运行项目时,组件的移动方式与设计时不同。 我无法滑动滚动视图来查看所有内容。 我是一名学生,我也遇到过这些

回答 1 投票 0

如何检查ScrollView是否实际显示?

我有这个会改变的动态文本。仅当用户阅读所有文本时,我才需要启用此布局的按钮。 (滚动到底部)。这是用我的方法工作的

回答 3 投票 0

在用户滚动时更改视图的位置

我有一个长屏幕,我使用 NestedScrollView 和 RecyclerView ,如下图所示: 正如你所看到的,我在屏幕底部有一个 commentConatiner 布局,当前用户看到我...

回答 1 投票 0

为什么我显示空白屏幕?

从“react”导入React; 从“react”导入类型 {PropsWithChildren}; 进口 { 方面, 平面列表, 图像, 可按压, 安全区域视图, 滚动视图, 状态栏, 样式表, 文本,

回答 1 投票 0

Android:ScrollView 无法在键盘退出时滚动

我有一个带有一些视图的布局,其中一个是 EditText。布局很容易适合一页,但是,当软键盘退出时,布局不会滚动。 这是我的布局的回顾: <...

回答 12 投票 0

如何制作全屏 Activity,状态栏位于其顶部,而当 Activity 聚焦于 editText 时,滚动条未完全滚动?

问题是,当我在 EditText 中输入文本时,ScrollView 不起作用并且不会在我的活动中滚动 有趣的状态栏颜色(活动:活动){ val 窗口 = Activity.window //...

回答 4 投票 0

如何在Scrollview底部放置按钮

我已经尝试到处搜索,但我似乎无法弄清楚这一点。基本上,我有一个带有 Scrollview 和其中元素的布局。我想在滚动视图中放置一个按钮,这将...

回答 3 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.