I'm trying to make a dotted line. I'm using this right now for a solid line:
LinearLayout divider = new LinearLayout( this );
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 2 );
divider.setLayoutParams( params );
divider.setBackgroundColor( getResources().getColor( R.color.grey ) );
I need something like this, but dotted instead of solid. I'd like to avoid making hundreds of layouts alternating between a transparent layout and solid layout.
This will help you. Creating dotted line using XML. Create xml in drawable folder and give that background to the item to which you want to set dotted border.
----> Creating XML Background "dashed_border"
-----> Adding that background to item
I've created a library with a custom view to solve this issue, and it should be very simple to use. See https://github.com/Comcast/DahDit for more. You can add dashed lines like this:
I have custom a dashline which support horizontal&verical dash line . code below: