2017-04-02 198 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