I have one fragment layout with a background image. Programmatically I have to add the different layer to this image because I want to add some particular details depending of some data. There are three different details that it can change in 3 different way. ( there is a thread that works at 5/10hz and it loads the right details)
The following is my first implementation. In this version, I have done all of works in XML layout and in a programmatically way, when the user clicks on a certain button, I set the visibility of each image view. I have seen that is much expensive, and sometimes the inflate layout return null:
<RelativeLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
>
<ImageView
android:id="@+id/layer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:src="@drawable/ballgreen"/>
<ImageView
android:id="@+id/layer2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:src="@drawable/ballred"/>
<ImageView
android:id="@+id/layer3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:src="@drawable/ballyellow"/>
... 6 more image view layer....
</RelativeLayout>
Then I thought to use an async task to decode all drawable image, make a bitmap fusion and in a post execute load the result bitmap in a single image view. But the asynctask is not the better way to implement, because the user can click on that button many times and each time I have to call new asynctask ..
Are there a clever ways to implement all of this?
Goodbye and thanks a lot :)
EDIT : each layer is a detail that thread can add to that image. For example : a car, a tree, a red ball ecc ecc. In the xml example for me each imageview is a layer, and this is wrong. But I don't know the clever way to implement ..
EDIT2 : Moreover I know the maximum amount of layer, but there are many combinations. there are 3 point and for each point I can choice between 3 differents details
Edit3: i add some details , there is a thread that change laYer and not the user