我尝试设置ScrollView的android:scrollbars="none"
属性,但问题是在输入信息时键盘已启动然后如果您尝试滚动则不会滚动直到布局结束。
我使用布局
中<ScrollView>
标记内的代码行隐藏滚动条
android:scrollbarThumbVertical="@null"
它完全适用于三星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);
答案 0 :(得分:5)
@null
值会导致NullPointerException
。您可以使用透明drawable:
android:scrollbarThumbVertical="@android:color/transparent"