There are many ways we can add a Horizontal line/rule in an Android Layout.xml file. One of the ways is to create a table row with background color and a height of say 1-2dp.

Horizontal line in Android Layout
Source Code : layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:padding="10dp"
android:id="@+id/textView" />
<TableRow
android:id="@+id/hr"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#444"></TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:id="@+id/textView2" />
<TableRow
android:id="@+id/hr1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#444"></TableRow>
</LinearLayout>

Output
More Posts related to Android,
- Change Android Toast background color
- Maven : java.lang.ClassNotFoundException: Xmx512m
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Android Alert Dialog with Checkboxes example
- Android Error Generating Final Archive - Debug Certificate Expired
- How to add Newline to text in Android TextView
- Read Text file from SD Card : Android Programming
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException
- ActivityManager Warning: Activity not started, its current task has been brought to the front
- INSTALL_FAILED_INSUFFICIENT_STORAGE Android Error
- Android Developers Bluetooth Tutorial
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix]
- Android: Save Data in local Db using Android Room
- Channel 50 SMSes received every few minutes Android Phones
- 21 Useful Android Emulator Short-cut Keyboard Keys
- Changing Android Intent Tittle using java code
- Android : No Launcher activity found! Error
- How to change TextView or EditText Text Color on Focus and on Press
- How to display Toast on Button Click : Android
- Android : Execute some code after back button is pressed
- Stop android adb service from command prompt or terminal
- [Soluiton] You already have the latest version of Android Studio installed
- Create Custom Android AlertDialog
- Android R Cannot Be Resolved To A Variable
- How to make Android EditText not editable
More Posts:
- appcompat_v7 errors after updates to API level 21 Material Theme - Android
- How to enable Do Not Disturb (DND) mode in Microsoft Teams - Teams
- Multiline EditText in Android Example - Android
- How to remove app from Dock when closed [macOS Big Sur] - MacOS
- How to make macOS Terminal window Transparent (or Opaque) - MacOS
- That did'nt work, Issue type User not in directory - SharePoint external access error - SharePoint
- Check Wifi Connection static Android Programming - Android
- Convert text to random case using Notepad++ - NotepadPlusPlus