gpt4 book ai didi

android - horizo​​ntalscrollview 的 fillviewport 禁用滚动?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:34:20 26 4
gpt4 key购买 nike

我有这个布局,如果我不在我的 Horizo​​ntalScrollView 中使用 fillviewport=true,它会奇怪地缩放(可能是由于不明智的布局嵌套)。

当 fillviewport=false 时一切正常(除了奇怪的缩放),但当 fillviewport=true 时,缩放是完美的但没有滚动发生。

这是布局(注意:我知道你不应该将 webview 放在 scrollview 中。但是 webview 没有 smoothscrollto 也没有公开 setscroller 方法,所以...... bleh。)

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webContainer"
android:layout_below="@+id/titlebar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webZ"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</HorizontalScrollView>

设置 android:fillViewport="true"通常不会禁用 View 中的滚动,对吗?

只是应该确保 ScrollView 填满视口(viewport),而不管其内容的大小,嗯?我认为视口(viewport)是屏幕的可见区域,webview 中可见区域边缘肯定有更多内容,我无法再滚动到它了。

我可以从 logcat 中看到正在调用滚动方法,它们只是不改变屏幕。 (除非我将 fillviewport 设置为 false。)

最佳答案

问题是您使用了“fill_parent”,意思是“和我的 parent 一样大”。请改用 wrap_content 作为宽度。

关于android - horizo​​ntalscrollview 的 fillviewport 禁用滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5307355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com