android - How to avoid calling bringToFront() in onDraw of custom view? -


i have custom view can see in activity_main.xml. right hidden under camera fragment. want show on top of it.

<framelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/fragment_container"     android:layout_width="match_parent"     android:layout_height="match_parent" > <com.snappiesticker.cwac4.stickerview     android:layout_width="match_parent"     android:layout_height="match_parent" />     </framelayout> 

this class itself:

public class stickerview extends view {      bitmap bitmap;      float x = 2;     float y = 2;      public stickerview(context context, attributeset attrs) {         super(context,attrs);         bitmap = bitmapfactory.decoderesource(context.getresources(), r.drawable.paunch);     }       @override     public void ondraw(canvas canvas) {         super.ondraw(canvas);         canvas.drawbitmap(bitmap, x, y, null);         // wanted put here cause loop described below.       }   } 

by loop, mean: ondraw called, calls bringtofront, asks layout re-rendered. calls ondraw, calls bringtofront, etc. etc.

this want avoid.

this instantiated in mainactivity.

public class mainactivity extends activity implements camerahostprovider {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_main);          democamerafragment current = new democamerafragment();          getfragmentmanager().begintransaction()                 .add(r.id.fragment_container, current)                 .commit();         // can somehow tell render custom sticker view @ front here?     } } 

did understand correctly, want have custom stickerview remain on top of camera fragment? if case refine layout ;

<framelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >     <framelayout         android:id="@+id/fragment_container"         android:layout_width="match_parent"         android:layout_height="match_parent" />     <com.snappiesticker.cwac4.stickerview         android:layout_width="match_parent"         android:layout_height="match_parent" /> </framelayout> 

using layout camera fragment added below stickerview , there's no need call bringtofront() @ all. if use root layout fragment container fragment added after custom view i.e above it.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -