将FrameLayout转换为图像

时间:2020-04-14 13:30:18

标签: android textview android-imageview android-framelayout

我有一个FrameLayout,其中有一个ImageView作为子元素。在此ImageView之上,我让用户通过TextView创建了一些文本。它工作正常。 但现在我想将FrameLayout及其ImageView(以及进一步动态添加的TextViews)作为一个整体发送。

我该怎么做?

这是我的XML布局:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <FrameLayout
        android:id="@+id/image_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".FirstFragment">

        <ImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:contentDescription="@string/imageview_holding_the_image" />
    </FrameLayout>
</layout>

这里是在运行时创建一个简单的TextView并将其放在FrameLayout的{​​{1}}之上的代码,以便原始图像被{{ 1}}:

ImageView

现在,当我想创建该“扩展”图像(原始图像+ TextView)时,该怎么办?

0 个答案:

没有答案