I have some code which I run in normal activities in method onFocusChanges
, it is important to run it just there as the code requires the activity to be loaded first as it get images width and heights from the view:
in MainActivity
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
SizeModifier sizeModifier = SizeModifier.getInstance(this);
sizeModifier.adjust
}
so all this is working just fine, the problem is this main view contains a fragment changes according to button press like that
FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.main_view_fragment,fragment).commit();
the fragment of course has activity and xml, I want now when the fragment open to run the previous code when focus changes but the problem is fragments does not have onFocusChange
, I tried all onStart
onResume
onCreateActivity
but non seems to work as I want, of course the method is called but all images widths are returned 0,
so is there away to be sure that images will return correct width or some alternative to onFocusChanges