2017-04-02 192 views

回答

0

你可以尝试的android:background属性与您需要的边框颜色值添加到您的ImageView。然后将android:padding属性添加到ImageView,并使用所需边框宽度的值。这不是最优雅的解决方案,但这是可以理解的,对于新的开发人员来说,这样做会很好。例如:

<ImageView 
    android:id="@+id/list_item_icon" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/android_image" 
    android:background="color/list_item_icon_border_color" 
    android:padding="1dp" 
    /> 

也许正确的方法是使用自定义XML drawables。您可以在Google中检查是否使用自定义XML drawable为ImageView创建边框。不过,与上面提到的方法相比,它更复杂一些,它可能是从XML定义的自定义drawable开始的绝佳方式。迟早你必须了解它,别无他法。对于圆形边框检查这个帖子 - 用自定义XML可绘制的很好和清晰的解释: Create circular border around ImageView

+0

我需要广场.. –

+0

btn的边界 –

+0

查看我在评论底部为您提供的链接。实际上,当我写这个时,你还没有上传截图,这就是为什么我开始解释最常见的情况 - 矩形。检查评论底部的链接,你会发现你的答案 –

0

在项目的布局,你可以把一个视图与1DP或宽度1DP的heigth,并与一些填充它。这是一个带有文本和底部分隔线的列表项。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 
    <View 
     android:layout_width="match_parent" 
     android:layout_height="1dp" 
     android:background="@color/colorPrimary"/> 
</FrameLayout> 
+0

code smple pls? –

+0

对不起,我newb –

+0

@JibRealNadela现在尝试 – jorgeavilae