要向Android Spinner添加分割线,可以通过自定义Spinner的样式来实现。以下是一种简单的方法:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="1dp" android:color="#000000" />
</shape>
<style name="SpinnerStyle" parent="Widget.AppCompat.Spinner">
<item name="android:background">@drawable/spinner_divider</item>
</style>
<Spinner
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/SpinnerStyle"/>
这样就可以向Spinner添加分割线了。您可以根据需要修改分割线的颜色、粗细和样式。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:android slidingtablayout分割线怎么添加