如果在CSS中创建一个初始边框,浏览器会改变每条边的边框颜色,以使形状看起来从其父级突出。
有没有一种简单的方法可以在Android布局中执行此操作,还是需要手动设置每个线条颜色?
更新 - 添加了以下示例:
答案 0 :(得分:1)
我不知道有任何原生支持视图有边框。你的问题让我想起了我最近看到的这个问题:
Is there an easy way to add a border to the top and bottom of an Android View?
答案 1 :(得分:1)
将ImageView的背景设置为9修补的可绘制资源,边缘周围有所需的阴影/斜角。让我们说它需要5个像素来创建你想要的效果。然后将ImageView的填充设置为5像素。然后将位图设置为任何图像。
ImageView.setBackgroundDrawable
ImageView.setPadding
ImageView.setImageBitmap
更简单,使用带有条纹边框的形状并将其设置为视图的背景:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000" />
<stroke android:width="1px" android:color="#ffffff" /></shape>