I'm a student in an android development program. I've built a few apps and I had an idea to use a very simple TextView
to draw a line across the screen to visually separate a page element. The TextView
would hold no text, it has no function or use other than to separate two elements with a horizontal rule. I'm using it in a ConstraintLayout
.
Can anyone give me a reason as to why this is NOT a good idea? What would the best practices be otherwise? Is it normal to use an empty TextView
in this manner?
It's perfectly fine to do that, but it's unnecessary to use a TextView
specifically: A TextView
with no text is just a View
.
You can just create a View
with whatever height and background color and use that:
<View
android:layout_width="match_parent"
android:layout_width="1dp"
android:background="@color/my_divider_color" />
Replace 1dp
with whatever height you want and @color/my_divider_color
with whatever color you want the divider to be.