Button does not appear in one activity and appears in another

0

I have a problem that I can not identify where it is. I have a layout that runs a video, with a button in front, but the button does not appear even though when I click on the button area it works normally.

Thebuttonshouldappearintheredarea.

ButIhaveanotherlayoutrotatedidentical,wherethebuttonappears,andbothhavethesamecode.

Itappearsintheredareanormally,andalsoworks.

Thisisthelayoutwherethebuttondoesnotappear

<?xmlversion="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 error is because I can not find it, if I can help I thank

    
asked by anonymous 27.03.2018 / 04:16

1 answer

0

If I understood correctly, the desired result would be the button above ( on top ) of VideoView.

Try to enclose both the VideoView and the button within FrameLayout

  

FrameLayout is designed to lock an area on the screen to display a single item. [...] You can, however, add multiple children to a FrameLayout. Daughters Views are drawn in a stack, with the daughter most recently added at the top .

<?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">

    <FrameLayout
        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_gravity="center"
            android:id="@+id/vb_view"/>

        <ImageButton
            android:id="@+id/vb_lutadores"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/lutadores"
            android:layout_gravity="center_horizontal|bottom"
            android:layout_marginBottom="50dp" />

    </FrameLayout>

</RelativeLayout>

Note that the RelativeLayout of the third level has been removed and the properties relative to it in ImageButton and VideoView have been replaced with android:layout_gravity as specified here

    
27.03.2018 / 16:09