This article shares the specific code of adding horizontal lines below the Android implementation text for your reference. The specific content is as follows
public class WhiteTextviewWithWhiteBottomLine extends LinearLayout { private Context mContext; public WhiteTextviewWithWhiteBottomLine(Context context) { this(context, null); } public WhiteTextviewWithWhiteBottomLine(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public WhiteTextviewWithWhiteBottomLine(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mContext = context; initViews(); } private TextView textView; private View viewLine; private void initViews() { View view = (mContext, .view_textview_with_bottom_line, null); textView = (.tv_view_textview_with_line); viewLine = (.view_view_textview_with_line); (view); setSelected(false); } public void setTextViewText(String s) { (s); } public void setLineColor(@ColorInt int color) { (color); } public void setSelected(boolean isSelected) { if (isSelected) { (VISIBLE); } else { (GONE); } } public boolean isSelected() { if (() == ) { return true; }else { return false; } } }
Layout file:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical"> <TextView android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" android:text="test" android:textColor="@color/white" android:textSize="12sp" /> <View android: android:layout_width="30dp" android:layout_height="1dp" android:layout_gravity="center_horizontal" android:background="@color/white" /> </LinearLayout> </LinearLayout>
If you want to change the color of text and lines, directly modify the content in the layout file.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.