What i have done: I have set the bitmap for a relative layout as below
RelativeLayout root;
root= (RelativeLayout) itemView.findViewById(R.id.r
There are a couple of ways you can do this:
1. Try:
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rel);
layout.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(layout.getDrawingCache());
layout.setDrawingCacheEnabled(false);
2. Or try:
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rel);
Bitmap b = Bitmap.createBitmap( layout.getLayoutParams().width, layout.getLayoutParams().height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
layout.layout(layout.getLeft(), layout.getTop(), layout.getRight(), layout.getBottom());
layout.draw(c);
To get the current ImageView
1. To get current position, use
ViewPager viewPager = getView().findViewById(r.id.pager);
int position = viewPager.getCurrentItem();
2. To get the current View
, use
View currentView = viewPager.getChildAt(int position);
This currentView
is the View
created by the onCreateView()
method of the current Fragment
.
3. To get the ImageView
, use
ImageView currentImage = (ImageView)currentView.findViewById(R.id.image);
where R.id.image
is the ImageView
object you want from the current Fragment
.