Ral*_*ann 5 android android-layout shapedrawable
我有以下可绘制的形状:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:width="1dp"
android:color="#e0e0e0" />
</shape>
Run Code Online (Sandbox Code Playgroud)
并将其与此图像一起使用:
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:src="@drawable/line" />
Run Code Online (Sandbox Code Playgroud)
当我设置android:layout_height为 1dp 时,形状不可见。如果android:layout_height设置为 2dp,则形状可见。
为什么我必须使用 2dp 的高度?
拉尔夫
这是一个笔画,所以它围绕着形状。这意味着它会穿过两侧的线,因此需要两倍的笔画宽度。
你可以<size>在你的形状中设置标签并将其放在 1dp 和<solid android:color="">颜色上