Bin*_*ran 0 android android-layout
我正在尝试在列表的行布局中绘制垂直线(回收站视图)。行应该在布局的左边对齐,左边距为 20dp,行高应该是自动的,当行布局的内容增加时,垂直线对齐布局的左对齐也应该增加。
我尝试通过在 drawable 文件夹中绘制垂直线来添加线条并将其添加到布局的背景中。但问题是线只出现在一半
可绘制:vertical_line.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="10">
<shape
android:shape="line">
<stroke
android:width="1dp"
android:color="#ff00ff"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_two">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="@drawable/vertical_line"
>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
如何在具有自动高度的布局左侧绘制一条线?
您可以使用View垂直线而不是形状:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:background="#ff00ff"/>
<TextView
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="text"
android:textColor="@color/white"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4017 次 |
| 最近记录: |