【问题标题】:Android: Draw a picture frame around any size imageAndroid:在任何尺寸的图像周围画一个相框
【发布时间】:2015-07-31 21:25:08
【问题描述】:
【问题讨论】:
标签:
android
xml
imageview
frame
nine-patch
【解决方案1】:
您可以为框架创建一个边框图像,然后使用FrameLayout 来定位框架的ImageView 和图片的ImageView,在图片上设置layout_margin 以便它是相对的插图到框架 - 例如:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp"
android:layout_height="400dp">
<ImageView
android:id="@+id/picture_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/picture_frame" />
<ImageView
android:id="@+id/picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/picture"
android:layout_margin="10dp" />
</FrameLayout>
您可能需要考虑使用 9patch png 作为框架,具体取决于您对良好缩放的要求。