TextView的水平上滚动型在android系统?
你能告诉我,当我们选择图库视图
的项目列入涉及到屏幕的中心如何限制呢?我想只是那里有我点击该项目。怎么样?简单的一句话,我想水平列表视图。怎么样?
Can you tell me when we select an item in GalleryView
its comes to the center of the screen how to restrict it? I want to just be there where i click that item. How? Simple words, I wanna horizontal Listview. How?
感谢
HI,
我建议你检查了的你好,画廊谷歌文档,它是很清楚。画廊是设计,因为他们说:在锁定在中心当前选择水平滚动列表显示的项目。结果
你只需要通过TextAdapter更换ImageAdapter,并把TextViews会代替ImageViews的。它的实际工作完全像一个ListView。所以你知道如何做一个列表视图,这应该很容易。
I would advise you check the "Hello, Gallery" on the google doc, it is very clear. Gallery is design to "display items in a horizontally scrolling list that locks the current selection at the center", as they say.
You just need to replace the ImageAdapter by TextAdapter, and put TextViews in it instead of ImageViews. It actually work exactly like a Listview. so you know how to do a Listview, this should be easy.
修改
这是我认为一个很好的解决方案:结果
您需要修改画廊的风格。由于默认情况下它的定义是这样的:
EDIT
Here is I think a nice solution :
You need to change the style of the gallery. As default it is defined like that :
<style name="Widget.Gallery">
<item name="android:fadingEdge">horizontal</item>
<item name="android:gravity">center_vertical</item>
<item name="android:spacing">-20px</item>
<item name="android:unselectedAlpha">0.85</item>
</style>
所以,你需要在你的文件夹中的画廊创建自己的styles.xml也放到了它:
So you need to create your own styles.xml in your folder gallery and put that in it :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="gallery" parent="android:Widget.Gallery">
<item name="android:fadingEdge">horizontal</item>
<item name="android:gravity">center_vertical</item>
<item name="android:spacing">0px</item> <!--This gives you no spacing between elements -->
<item name="android:unselectedAlpha">1</item> <!--This puts all elements the same alpha -->
</style>
<resources>
这给了我这样的:结果结果
现在,我敢肯定,我们可以通过与画廊和风格的各种属性打得到更好的结果,但我认为这是你的好领导;)
This gives me this :
Now I'm sure we can get better result by playing with the various attributes of the gallery and the style, but I think this is a good lead for you ;)