将多个TextView合并到位图上 - 我应该使用画布吗?

时间:2018-06-08 10:09:45

标签: java android canvas bitmap

我发现您可以在bitmap上添加或合并textviews。我有4 image我要合并到send的顶部。

以下是我想要实现的屏幕截图(尽管此时这是与图像顶部分开的文字视图):

图片位于textviews下方。右上角的图像标题是用于什么图像否则

Textviews with Image

所以我想要做的就是,一旦我点击image bitmap按钮,它就会打印出#34;或者将这些Textviews合并到下面的textviews,以便我可以将图像(包含Canvas.draw())保存或发送到我的服务器/设备作为一个文件。

到目前为止,我已经使用了{{1}}方法,虽然它似乎相互覆盖,我试图保持与屏幕截图相同的布局。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

试试这个......

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

    >
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottomLayID"
        />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:orientation="vertical"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2"
            android:padding="8dp"
            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Detail work order"
                android:textStyle="bold"
                android:gravity="center"
                android:layout_weight="0.5"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Image"
                android:textStyle="bold"
                android:gravity="center"
                android:layout_weight="1.5"
                />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2"
            android:padding="8dp"
            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:gravity="center"
                android:layout_weight="0.5"
                />
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textStyle="bold"
                android:gravity="center"
                android:layout_weight="1.5"
                />
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/bottomLayID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentBottom="true"
        >
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Open Camera"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Send Image"
            android:background="#99d72e"/>
    </LinearLayout>
</RelativeLayout>

将背景作为透明色和边框提供给textview。

您可以通过

将位图设置为imageview
ImageView mImg;
mImg = (ImageView) findViewById(R.id.(your xml img id));
mImg.setImageBitmap(img);