0
I have a problem I don’t know where it is. I have a layout that runs a video, with a button in the front, only that the button does not appear although when I click on the area of the button it works normally.
The button should appear in the area in red.
Only I have another identical rotated layout, where the button appears, and the two have the same code.
It appears in the red area normally, and also works.
This is the layout where the button does not appear
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:rotation="180"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rotation="180"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:id="@+id/vb_view"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/vb_lutadores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/lutadores"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</FrameLayout>
And that’s his code
package br.com.mscp.multiboxe;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageButton;
import android.widget.VideoView;
public class Vb extends Activity {
ImageButton vb_lutadores;
VideoView vb_view;
Uri vb_video;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.vb_layout);
vb_lutadores = (ImageButton) findViewById(R.id.vb_lutadores);
vb_lutadores.setEnabled(false);
vb_view = (VideoView)findViewById(R.id.vb_view);
vb_video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.vb);
vb_view.setVideoURI(vb_video);
vb_view.start();
vb_lutadores.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Vb.this, Menu_lutadores.class));
finish();
}
});
Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
vb_lutadores.setEnabled(true);
vb_lutadores.bringToFront();
}
};
handler.postDelayed(runnable, 800);
}
}
This is the layout where the button appears
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:id="@+id/vc_view"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/vc_lutadores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/lutadores"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</FrameLayout>
And that’s the code
package br.com.mscp.multiboxe;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageButton;
import android.widget.VideoView;
public class Vc extends Activity {
ImageButton vc_lutadores;
VideoView vc_view;
Uri vc_video;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.vc_layout);
vc_lutadores = (ImageButton) findViewById(R.id.vc_lutadores);
vc_lutadores.setVisibility(vc_lutadores.INVISIBLE);
vc_lutadores.setEnabled(false);
vc_view = (VideoView)findViewById(R.id.vc_view);
vc_video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.vc);
vc_view.setVideoURI(vc_video);
vc_view.start();
vc_lutadores.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Vc.this, Menu_lutadores.class));
finish();
}
});
Handler handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
vc_lutadores.setVisibility(vc_lutadores.VISIBLE);
vc_lutadores.setEnabled(true);
vc_lutadores.bringToFront();
}
};
handler.postDelayed(runnable, 800);
} ´
}
Someone knows where the mistake is because I can’t find it, if you can help I appreciate it
When I test with these modifications the video view is no longer in full screen, it has a white bar on top. And if I try to add Relativelayout with Alingparent in the video view the button disappears again
– Mickael Cruz
After many tests, the only solution I found was to take the rotations and use the image already rotated, because without them the button appears, I just can’t understand why
– Mickael Cruz