ale*_*iki 5 xml android scroll android-recyclerview
我有一个用于回收器视图的自定义垂直滚动条,但是用于显示项目位置的拇指有点太大,并且在顶部时处于关闭位置。
在styles.xml 中,我使用thumb.xml 和track.xml 文件为自定义轨道和thumb 定义了自定义滚动条。在 recyler.xml 中,我添加了一个 style 属性来显示自定义滚动条,以及填充。
关于如何解决此问题的任何想法,我尝试更改 thumb.xml 中的宽度和高度,但它不起作用。谢谢!
Styles.xml 文件:
<resources>
<style name="AppTheme" parent="@style/Theme.Leanback">
<item name="@attr/scrollbarStyle">@style/scrollbar_shape_style</item>
</style>
<attr name="scrollbarStyle" format="reference"/>
<style name="scrollbar_shape_style">
<item name="android:scrollbarAlwaysDrawVerticalTrack">true</item>
<item name="android:scrollbarStyle">outsideOverlay</item>
<item name="android:scrollbars">vertical</item>
<item name="android:fadeScrollbars">false</item>
<item name="android:scrollbarThumbVertical">@drawable/thumb</item>
<item name="android:scrollbarTrackVertical">@drawable/track</item>
<item name="android:scrollbarSize">8dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
拇指.xml 文件:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#ffffff"
android:startColor="#ffffff" />
<corners android:radius="5dp" />
<size android:width="8dp" />
<size android:height="3dp" />
Run Code Online (Sandbox Code Playgroud)
track.xml 文件:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="0"
android:endColor="#9BA3C5"
android:startColor="#8388A4" />
<stroke
android:width="7dp"
android:color="#00ffffff"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
回收商的 xml 文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="383dp"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
style="@style/scrollbar_shape_style"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingEnd="50dp"
android:paddingStart="0dp"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我管理滚动条上的拇指以固定大小。这是修复大小的thumb.xml 文件
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:gravity="top">
<shape android:shape="rectangle">
<corners android:radius="100dp" />
<solid android:color="#e9eef2" />
<size
android:width="5dp"
android:height="25dp" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6776 次 |
最近记录: |