Android Can';你不划清界限吗?
我想画一条线作为Android Can';你不划清界限吗?,android,android-drawable,android-shapedrawable,Android,Android Drawable,Android Shapedrawable,我想画一条线作为ImageView的background。但它不起作用 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <solid android:color="#FF0000FF" /> <size android:width="10dp" android:height="2dp"/> </s
ImageView的background。但它不起作用
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<solid android:color="#FF0000FF" />
<size android:width="10dp"
android:height="2dp"/>
</shape>
只是一个演示
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dividing_line"
android:layout_marginLeft="10dp" />
ImageView
没有内容,因此大小将为0x0dp。如果需要分隔器,请尝试将宽度设置为match_parent
,将高度设置为您喜欢的值(2dp
)
更新:试试这个
在布局文件中:
<ImageView
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/dividing_line"
android:layout_marginLeft="10dp" />
可抽出式:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:width="2dp" android:color="#0000FF"/>
<size android:height="2dp" />
</shape>
它对我有用
正如作者所指出的,如果你只是想要一个除法器,那么更简单的解决方法就是添加一个除法器
<View android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/yourColor" />
到布局文件。ImageView
没有内容,因此大小将为0x0dp。如果需要分隔器,请尝试将宽度设置为match_parent
,将高度设置为您喜欢的值(2dp
)
更新:试试这个
在布局文件中:
<ImageView
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/dividing_line"
android:layout_marginLeft="10dp" />
可抽出式:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:width="2dp" android:color="#0000FF"/>
<size android:height="2dp" />
</shape>
它对我有用
正如作者所指出的,如果你只是想要一个除法器,那么更简单的解决方法就是添加一个除法器
<View android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/yourColor" />
到您的布局文件。显示您的布局xml@NikoYuwono你可以看到我的布局是将宽度改为10dp而不是包裹_contentn@Egos显示您想要的输出drow@EgosZhang在这之后,您是否将图像设置为ImageView?向我们显示您的布局xml@NikoYuwono你可以看到我的布局是将宽度改为10dp而不是包裹_contentn@Egos显示您想要的输出drow@EgosZhang之后,您是否将图像设置为ImageView?它不起作用。如果这个问题确实是关于分隔符的,只需将其添加到xml中即可:它不起作用。如果这个问题确实是关于分隔符的,只需将其添加到xml中即可: