【问题标题】:Changing Color of Scroll in ScrollView在 ScrollView 中更改滚动颜色
【发布时间】:2018-10-20 02:12:41
【问题描述】:

使用drawable 文件更改ScrollView 中滚动的颜色后,更改在预览和设计中可见,但在我的手机上不可见。

ScrollViewsn-p

<ScrollView
        android:layout_width="368dp"
        android:layout_height="150dp"
        android:layout_marginTop="8dp"
        android:scrollbarThumbVertical="@drawable/scollbar"
        android:scrollbarTrackVertical="@color/colorPrimaryDark"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        android:scrollbarSize="4dp"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2"
        app:layout_constraintVertical_bias="0.313">
<LinearLayout>
<TextView></TextView>
</LinearLayout>
</ScollView>

android:scrollbarThumbVertical 中的scollbar 不是错字。

谢谢。

【问题讨论】:

  • 请设置 android:layout_height="wrap_content"
  • 您可以为滚动视图中的布局提供背景颜色,而不是为滚动视图提供颜色。并尝试
  • @jayshah 如果我制作`android:layout_height = "wrap_content"` 那么,1. 我不需要滚动ScrollView,因为我在TextView 中的内容不够长。 2. 它不符合我的设计。我需要使用ScollView 在下方添加更多内容。我也尝试过更改,但没有成功。
  • @UmangBurman 我正在尝试更改 ScrollView 中 ScrollBar 的颜色

标签: android android-studio android-scrollview


【解决方案1】:

检查预览设备和您的设备的 API 版本。可能会有所不同。然后检查可绘制文件和您的设备的兼容性。您应该使所有设备兼容的可绘制文件具有属性以在所有设备中应用更改。

【讨论】:

  • 我检查一切都很好。
  • 你使用图像还是可绘制的 xml 文件?
  • 在 xml 字段下尝试.. 我从另一个堆栈溢出答案中得到它... schemas.android.com/apk/res/android">
  • 我正在使用兼容的可绘制 xml 文件。
  • 是看不到还是颜色没有变化?
猜你喜欢
  • 2022-01-25
  • 1970-01-01
  • 2011-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-07
相关资源
最近更新 更多