gpt4 book ai didi

android - 隐藏 ScrollView 棒在某些设备上会出现空指针异常

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:35:43 25 4
gpt4 key购买 nike

我尝试设置 android:scrollbars="none" ScrollView 的属性,但随后的问题是在输入信息时,键盘已启动,然后如果您尝试滚动,则它不会滚动到布局结束。

我在 <ScrollView> 中使用下面的代码行隐藏了滚动条棒布局中的标记

android:scrollbarThumbVertical="@null"

它在 Samsung s4 设备上运行完美,但在 LG 上它崩溃并出现以下异常 -

FATAL EXCEPTION: main 
java.lang.NullPointerException
at android.widget.ScrollBarDrawable.setAlpha(ScrollBarDrawable.java: 221)
at android.view.View.onDrawScrollBars(View.java: 11306)
at android.view.View.draw(View.java: 13567)
at android.widget.FrameLayout.draw(FrameLayout.java: 467)
at android.widget.ScrollView.draw(ScrollView.java: 1752)
at android.view.View.getDisplayList(View.java: 12512)
at android.view.View.getDisplayList(View.java: 12556)
at android.view.View.draw(View.java: 13285)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2931)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2801)
at android.view.View.draw(View.java: 13564)
at android.view.View.getDisplayList(View.java: 12512)
at android.view.View.getDisplayList(View.java: 12556)
at android.view.View.draw(View.java: 13285)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2931)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2801)
at android.view.View.draw(View.java: 13564)
at android.widget.FrameLayout.draw(FrameLayout.java: 467)
at android.view.View.getDisplayList(View.java: 12512)
at android.view.View.getDisplayList(View.java: 12556)
at android.view.View.draw(View.java: 13285)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2931)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2801)
at android.view.View.getDisplayList(View.java: 12510)
at android.view.View.getDisplayList(View.java: 12556)
at android.view.View.draw(View.java: 13285)
at android.view.ViewGroup.drawChild(ViewGroup.java: 2931)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java: 2801)
at android.view.View.draw(View.java: 13564)
at android.widget.FrameLayout.draw(FrameLayout.java: 467)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java: 2473)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java: 1206)
at android.view.ViewRootImpl.draw(ViewRootImpl.java: 2169)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java: 2041)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java: 1849)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java: 1009)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java: 4256)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java: 725)
at android.view.Choreographer.doCallbacks(Choreographer.java: 555)
at android.view.Choreographer.doFrame(Choreographer.java: 525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java: 711)
at android.os.Handler.handleCallback(Handler.java: 615)
at android.os.Handler.dispatchMessage(Handler.java: 92)
at android.os.Looper.loop(Looper.java: 137)
at android.app.ActivityThread.main(ActivityThread.java: 4917)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java: 511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 557)
at dalvik.system.NativeStart.main(Native Method)

它在某些设备上运行而不是在所有设备上运行的原因是什么?

正确执行此操作的唯一选择是按如下方式设置它 -

yourScrollView.setVerticalScrollBarEnabled(false);

最佳答案

@null 值导致 NullPointerException。您可以改用透明的可绘制对象:

android:scrollbarThumbVertical="@android:color/transparent"

关于android - 隐藏 ScrollView 棒在某些设备上会出现空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35335510/

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