ImageView上的内部边框

时间:2015-03-25 09:42:04

标签: android imageview border internal

我想在我的ImageView上放置一个内部边框,我设法做了一个带有填充和背景的外部边框但是我希望我的图像保持相同的大小(即使它的一部分是由边框分开的)所以我需要的是建立一个内部边界,但我无法弄清楚如何做,任何建议?

enter image description here

提前感谢您的回答。

1 个答案:

答案 0 :(得分:1)

这是解决方案..

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/ic_launcher" />

<LinearLayout
    android:layout_width="match_parent"
    android:background="@drawable/mBorder"
    android:layout_height="match_parent"></LinearLayout>

</FrameLayout>

mBorder.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

   <stroke android:width="4dp"
    android:color="#ff00ffff" />

</shape>
相关问题