小编ale*_*iki的帖子

Android 如何为回收站视图制作自定义滚动条

我有一个用于回收器视图的自定义垂直滚动条,但是用于显示项目位置的拇指有点太大,并且在顶部时处于关闭位置。

在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" …
Run Code Online (Sandbox Code Playgroud)

xml android scroll android-recyclerview

5
推荐指数
1
解决办法
6776
查看次数

Android Grid Layout Manager 列跨度

我需要为 Android TV 定制键盘,如下图所示。该布局有一个带有网格布局管理器的回收器视图,用于自定义行和列。

但是当我运行应用程序时,布局没有在最后一行显示正确的按钮宽度。“空格”按钮的跨度应为 4,“Shift”按钮 2 和“零”按钮 3。

android android-gridlayout android-recyclerview

2
推荐指数
1
解决办法
1250
查看次数