Annoying line to the right of the screen when using TableLayout
I'm using a TableLayout for an Activity and if I have more than a certain number of TableRows a vertical line appears to the right of the screen.
alt text http://dl.dropbox.com/u/5342899/device.png
开发者_开发技巧If I use fewer Views in my layout, the line disappears. If this is not a bug, where should I look in my layout for problems?
It is a scrollbar. It appears when your layout is longer than the screen. You can disable it on your TableLayout (android:scrollbars="none"
in XML or setVerticalScrollBarEnabled(false)
from code).
However, you shouldn't do that because if you add too much rows, the user simply won't see them.
If the scrollbar hides text, add a padding to the layout (android:padding="10dip"
).
The reason the line appears when you have over a certain amount of rows is because it is a ScrollBar, it means the amount of rows on your screen flow down below the visible page, the scroll bar allows the user to gesture towards the rest of the options.
In the same respect it's also why the bar disappears when there only a few rows, there's enough room for the rows to be shown correctly.
Bear in mind that if you disable the scrollbar and intend on deploying the app on other phones - especially phones with smaller screens - you run the risk of cutting out part of the UI from users
精彩评论