【问题标题】:Android: Draw a picture frame around any size imageAndroid:在任何尺寸的图像周围画一个相框
【发布时间】:2015-07-31 21:25:08
【问题描述】:

我基本上试图在 xml https://lh3.googleusercontent.com/1n_lKanRLjBPkXBr79vES3v3IwR20u5SDvQnbFztb7VOOFRlru6SRTX3RvNsp5PI2w=h900-rw 中做到这一点

有人知道怎么做吗?

【问题讨论】:

  • 你的意思是边框吗?
  • 如何在不使用图片的情况下使边框看起来像这样?
  • 你可以使用drawable

标签: 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 作为框架,具体取决于您对良好缩放的要求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 2020-08-15
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    相关资源
    最近更新 更多