recyclerview 设置分割线的高度
生活随笔
收集整理的這篇文章主要介紹了
recyclerview 设置分割线的高度
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
1.先創建一個xml文件,名稱隨便,例如:divide_gray_ten.xml? 內容如下:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> //矩形<solid android:color="#0000ff" /><size android:height="10dp" /> </shape>2.在代碼中如下操作即可
LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); DividerItemDecoration decor = new DividerItemDecoration(this, layoutManager.getOrientation()); decor.setDrawable(ContextCompat.getDrawable(this,R.drawable.divide_gray_ten)); //這里在就是 recyclerView.addItemDecoration(decor);3.運行代碼看看效果吧!
?
轉載于:https://my.oschina.net/f839903061/blog/1987855
總結
以上是生活随笔為你收集整理的recyclerview 设置分割线的高度的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php实现数值的整数次方
- 下一篇: 写一个脚本定时自动备份mysql到指定目