android ListView滚动条样式
有谁知道有关 android:scrollbarStyle 的任何文档吗?如果可能的话,我希望查看 4 个值中每个值的示例以及屏幕截图。我看到了外部和外部之间的区别内部类型,但是 Inset 和 Inset 是什么?起始部分都是关于什么的?我似乎没有看到 insideOutset 和 insideOutset 之间的区别。 insideInset 例如,同样,我没有看到 externalOutset 和 insideInset 之间的区别。外面开始。
提前致谢! 本
Does anyone know of any documentation on the android:scrollbarStyle? I'd like to see examples of each of the 4 values w/ screenshots if possible. I see the difference between outside & inside types, but what are the Inset & Outset parts all about? I dont seem to see a difference between insideOutset & insideInset for example, likewise, I don't see a difference between outsideOutset & outsideOutset.
thanks in advance!
Ben
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
没有像outsideOutset 和insideOutset 这样的值。可能的四个值是insideOverlay、insideInset、outsideOverlay、outsideInset
该文档位于以下两个链接...
http:// developer.android.com/reference/android/view/View.html#attr_android:scrollbarStyle
http://developer.android.com/reference/android/view/View.html#SCROLLBARS_INSIDE_INSET
我无法正确理解文档。
所以参考ApiDemos Scrollbar demo,我尝试了这个。但我发现insideInset和outsideOverlay没有区别。
这两个值是不同的,它应该同时作为Inset或Overlay
更新的scrollbar3.xml是
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/view1"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="insideOverlay"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view2"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="insideInset"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view3"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="outsideOverlay"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView>
<ScrollView
android:id="@+id/view4"
android:layout_width="100dip"
android:layout_height="120dip"
android:padding="8dip"
android:scrollbarStyle="outsideInset"
android:background="@android:color/white"
android:overScrollMode="never">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:background="@android:color/darker_gray"
android:text="@string/scroll_text" />
</ScrollView></LinearLayout>
我希望有人会看到这一点并澄清...
上面的答案不太适合我,所以我想出了以下答案:
如果这是您想要实现的目标,请执行以下操作:
ListView:
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay"
android:scrollbarThumbVertical="@drawable/scrollbar" />
滚动条可绘制:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@android:color/transparent"
android:width="20dp"/>
<item
android:drawable="@android:color/holo_red_dark"
android:right="18dp" />
</layer-list>
感谢这个答案
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
这是一个更详细的示例。我设置了背景颜色,以使这里发生的事情更加明显。
一、颜色:
scrollbarTrackVertical
)让我们定义两个部分:
让我们分别考虑一下
scrollBarStyle
的两个部分:inside
-滚动条出现在内容区域内(内边距环绕内容和滚动条)outside
- 滚动条出现在内容区域之外overlay
- 滚动条覆盖其所在部分的右边缘inset
- 滚动条将其所在部分推向左侧,占用自己的空间布局 xml 如下所示
以编程方式设置滚动条样式:
Here's a little more detailed example. I set up background colors to make it more obvious what's going on here.
First, the colors:
scrollbarTrackVertical
for the two "inset" examples)Let's define two sections:
Let's think about the two parts of the
scrollBarStyle
separately:inside
- the scrollbar appears inside the content area (the padding wraps around both the content and the scrollbar)outside
- the scrollbar appears outside the content areaoverlay
- the scrollbar overlays the right edge of the section it's ininset
- the scrollbar pushes the section it's in to the left, taking up its own spaceThe layout xml appears below
To set the scrollbar style programmatically: