I am working on an Android application. In my app I have to show the video in the corner of the screen.Then If the user double clicked or longclicked I have to expand the video in to full screen. So i used the following code.
vd.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
if (!flag) {
DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics);
android.widget.LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) vd.getLayoutParams();
params.width = metrics.widthPixels;
params.height = metrics.heightPixels;
params.leftMargin = 0;
vd.setLayoutParams(params);
flag=true;
}
else{
DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics);
android.widget.LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) vd.getLayoutParams();
params.width = (int) (200);
params.height = (int) (200);
params.leftMargin = 30;
vd.setLayoutParams(params);
flag = false;
}
return true;
}
});
But nothing happeneds on the long click.Long click is working fine for button but not for Videoview. Please help me to find a solution. Thanks in advance