底部圆角-Android
我一直试图解决这个问题,但无论我做什么,我就是不能得到底部圆角的方式,我想,我使用以下底部圆角-Android,android,android-layout,Android,Android Layout,我一直试图解决这个问题,但无论我做什么,我就是不能得到底部圆角的方式,我想,我使用以下 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle"> <str
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<stroke android:width="0dp" />
<solid android:color="?attr/colorPrimaryDark" />
</shape>
</item>
<item android:top="0dp" android:bottom="1dp">
<shape
android:shape="rectangle">
<stroke android:width="0dp"/>
<solid android:color="?attr/colorPrimary"/>
<corners android:radius="15dp" android:bottomRightRadius="15dp" android:bottomLeftRadius="15dp" android:topLeftRadius="0dp" android:topRightRadius="0dp"/>
</shape>
</item>
</layer-list>
结果如下
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<stroke android:width="0dp" />
<solid android:color="?attr/colorPrimaryDark" />
</shape>
</item>
<item android:top="0dp" android:bottom="1dp">
<shape
android:shape="rectangle">
<stroke android:width="0dp"/>
<solid android:color="?attr/colorPrimary"/>
<corners android:radius="15dp" android:bottomRightRadius="15dp" android:bottomLeftRadius="15dp" android:topLeftRadius="0dp" android:topRightRadius="0dp"/>
</shape>
</item>
</layer-list>
它创建了角点,但它添加了灰色(
colorPrimaryDark
),我希望它是白色(colorPrimary”
)并带有一条灰线-我知道如何实现这一点吗?如果你只想要底部边框,一个可绘制的形状就足够了。你不需要图层列表。
试试这个
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="@color/green"/>
<solid android:color="?attr/colorPrimary" />
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp" />
</shape>
当前代码的问题是第一个项目的颜色设置为纯色。这就是为什么显示灰色部分。如果您只需要底部边框,则可以绘制形状。您不需要图层列表。
试试这个
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="1dp" android:color="@color/green"/>
<solid android:color="?attr/colorPrimary" />
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp" />
</shape>
当前代码的问题是第一个项目有一个纯色集。这就是为什么显示灰色部分。稍微修改一下可以去掉顶部和侧面的线条:设置负偏移
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="?attr/colorPrimaryDark" />
<solid android:color="?attr/colorPrimary" />
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:radius="15dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp" />
</shape>
</item>
</layer-list>
不确定它是否能在所有设备/Android版本上正常工作。稍微修改一下可以去掉顶部和侧面的线条:设置负偏移量
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-1dp"
android:right="-1dp"
android:top="-1dp">
<shape android:shape="rectangle">
<stroke
android:width="1dp"
android:color="?attr/colorPrimaryDark" />
<solid android:color="?attr/colorPrimary" />
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:radius="15dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp" />
</shape>
</item>
</layer-list>
不确定它是否能在所有设备/Android版本上正常工作。嘿,谢谢你的回复,但这并没有划清界限:)在这里查看结果@Ali changestroke
到
不确定你的输出。.因为我看不到图像,它是全白色的。.我想你需要@SergeyGlotov,如果你的意思是
那也是广告在顶部画一条线,在这里看到结果嘿,谢谢你的回答,但这没有画一条线:)在这里看到结果@Ali将笔划
更改为
不确定你的输出..因为我看不到图像全是白色..我想你需要@SergeyGlotov,如果你的意思是
也在顶部添加了一条线,在这里看到结果y、 好的,我知道你在那里做了什么:)我必须做android:top=“-2dp”
使它在OREO&PIE(API 28)上不可见,这将是一个棘手的问题,我想在像素3XL上的AndroidX上,高DPs,我必须使用-3dp
使其不可见-我想没有实际的解决方案,对吧,我知道你在那里做了什么:)我必须做android:top=“-2dp”
使其在OREO&PIE上不可见(API 28),这将是一个棘手的问题,我想在AndroidX上,像素3XL,高DPs,我必须使用-3dp
使其不可见-我想没有实际的解决方案