Android的ListView的滚动条 [英] Android ListView Scrollbar

查看:129
本文介绍了Android的ListView的滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的列表view.I需要增加垂直滚动条的宽度。我改的android:scrollbarSize。但它不工作。也希望降低滚动thumb.Is它posiible的长度。请帮帮我。

 <的LinearLayout机器人:ID =@ + ID / LinearLayout01
 机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT
 的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>< ListView控件
 机器人:ID =@ + ID / list_view
 机器人:layout_width =FILL_PARENT
 机器人:layout_height =WRAP_CONTENT
 机器人:滚动条=垂直
 机器人:scrollbarAlwaysDrawVerticalTrack =真
 机器人:scrollX =0像素
 机器人:scrollY =0像素
 机器人:背景=#515151
 机器人:layout_weight =1
 机器人:scrollbarStyle =outsideOverlay
 机器人:分=#FFF
 机器人:fadeScrollbars =假
 机器人:scrollbarSize =20dip/> < / LinearLayout中>


解决方案

您滚动条将扩展到资源的您指定宽度/高度的android:scrollbarTrackHorizo​​ntal 的android:scrollbarTrackVertical

这似乎是做到这一点,我可以想出现在唯一的出路,我不会用它去猴子身边了;)

所以,如果你想要一个8像素宽的水平轨道和一个12像素高的垂直轨道。创建一个PNG是8像素宽的水平轨道。创建一个PNG是12像素高的水平轨道。你的十个补丁的的android:scrollbarThumbHorizo​​ntal 的android:scrollbarThumbHorizo​​ntal 将自动缩放内这些图像

 <项目名称=机器人:scrollbarTrackHorizo​​ntal> @绘制/ png_12px_high< /项目>
<项目名称=机器人:scrollbarTrackVertical> @绘制/ png_8px_wide< /项目>

I created a list view.I need to increase the width of the vertical scrollbar. I changed android:scrollbarSize. But it is not working .Also want to decrease length of scrollbar thumb.Is it posiible. Please help me.

<LinearLayout android:id="@+id/LinearLayout01" 
 android:layout_width="fill_parent" android:layout_height="fill_parent" 
 xmlns:android="http://schemas.android.com/apk/res/android">

<ListView 
 android:id="@+id/list_view"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:scrollbars="vertical"
 android:scrollbarAlwaysDrawVerticalTrack="true"
 android:scrollX="0px"
 android:scrollY="0px"
 android:background="#515151"
 android:layout_weight="1"
 android:scrollbarStyle="outsideOverlay"
 android:divider="#FFF"
 android:fadeScrollbars="false"
 android:scrollbarSize="20dip"/>

 </LinearLayout>

解决方案

Your scrollbar will scale to the width/height of the resource that you specify for android:scrollbarTrackHorizontal and android:scrollbarTrackVertical.

This seems to be the only way to do it that I can figure out right now, and I'm not going to monkey around with it anymore ;)

So if you want an 8px wide horizontal track, and a 12px high vertical track. Create a PNG that is 8px wide for the horizontal track. Create a PNG that is 12px high for the horizontal track. Your nine patches for the android:scrollbarThumbHorizontal and android:scrollbarThumbHorizontal will automatically scale inside of these images.

<item name="android:scrollbarTrackHorizontal">@drawable/png_12px_high</item>
<item name="android:scrollbarTrackVertical">@drawable/png_8px_wide</item>

这篇关于Android的ListView的滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆