我如何在不使用任何库的情况下实现这种布局?
我尝试了一些类似于下面的代码,但无法获得完全相同的布局。
my_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:context=".MainActivity">
<RelativeLayout
android:background="@drawable/layout_border"
android:layout_margin="20dp"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_tick"
android:layout_width="17dp"
android:layout_height="17dp"
android:layout_marginLeft="20dp"
android:src="@drawable/tick" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/iv_tick"
android:layout_marginLeft="14dp"
android:layout_marginRight="20dp"
android:layout_toRightOf="@+id/iv_tick"
android:lineSpacingExtra="6dp"
android:text="This is my text. This is my text. This is my text. This is my text. "
android:textColor="#000"
android:textSize="16dp" />
<ImageView
android:src="@drawable/dotted_line"
android:foregroundGravity="left"
android:layout_below="@+id/iv_tick"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<!--<com.example.myapplication.DividerView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layerType="software"
android:color="#ff0000"
android:orientation="vertical"
android:dashLength="5dp"
android:dashGap="1dp"
android:dashThickness="1dp" />-->
</RelativeLayout>
</RelativeLayout>
dotted_line.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="2dp"
android:color="#ff0000"
android:dashWidth="4dp"
android:dashGap="4dp" />
</shape>
</rotate>
这是我使用上述代码获得的结果。如何获得类似我上面发布的图片那样的结果?
我甚至尝试了约束布局,但也无济于事。
![enter image description here](https://istack.dev59.com/QtwzT.webp)
SO
链接 https://dev59.com/wlcP5IYBdhLWcg3wDWRq 和其他库链接 https://github.com/vipulasri/Timeline-View - Android