gpt4 book ai didi

Android ListView thumb ScrollBar

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:30:14 25 4
gpt4 key购买 nike

我想看到下面的拇指滚动条:

http://www.androidpatterns.com/uap_pattern/scroll-thumb

我看到的是:

enter image description here

我的 XML 布局是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="xxaassss"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>

<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector" />

</LinearLayout>

我的 Java 代码 在 Activity 类的 onCreate 中(我从 Activity 类而不是 ListActivity 扩展):

        super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView list=(ListView)findViewById(R.id.list);
ArrayList<HashMap<String, String>> categoriesList = new ArrayList<HashMap<String, String>>();

for(int i=0;i<119;i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put(KEY_ID, String.valueOf(i));
//map.put(KEY_TITLE, "hello");
map.put(KEY_TITLE, Prayer.tip.getNthLine(i, true).replace("~", ""));
map.put(KEY_ARTIST, "");
map.put(KEY_DURATION, "");
map.put(KEY_THUMB_URL, String.valueOf(getResources().getIdentifier("img" + i, "drawable", getPackageName())));
categoriesList.add(map);

}
LazyAdapter adapter=new LazyAdapter(this, categoriesList);
list.setAdapter(adapter);

list.setFastScrollEnabled(true);

我没有发布 LazyAdapter 的代码,因为我认为它与快速拇指滚动条的样式无关。如果需要,我也可以发布该代码。

最佳答案

像这样更改您的 xml 代码

<com.google.ads.AdView
android:id="@+id/adView"`enter code here`
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="xxaassss"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>

<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:divider="#FFF"
android:fadeScrollbars="false"
style="@style/CustomTheme"
android:scrollX="0px"
android:scrollY="0px"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarSize="20dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />

以你的风格

<style name="CustomTheme" parent="android:Theme">
<item name="android:scrollbarTrackVertical">@drawable/scroll_track</item>
<item name="android:scrollbarThumbVertical">@drawable/scroll_thumb</item>

就像在 list 中

<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/CustomTheme">

关于Android ListView thumb ScrollBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17205017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com