Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:41:48+00:00 2026-06-15T19:41:48+00:00

I have a surfaceview with a click listener attached to it. When i click

  • 0

I have a surfaceview with a click listener attached to it.

When i click it, it shrinks it to half the width and half the Height… and places it in the Lower Right Corner via:

RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(  
    getWindowManager().getDefaultDisplay().getWidth()/2,
    getWindowManager().getDefaultDisplay().getHeight()/2    
);
rlp.setMargins(
  getWindowManager().getDefaultDisplay().getWidth()/2,    
  getWindowManager().getDefaultDisplay().getHeight()/2, 
  0, 
  0);

It works as intended, but i want to place behind it Dynamically a webView.

I tried:

WebView wv = makeWebView();
//makeWebView(); is a method of my mainActivity, which simple does.
private Webview makeWebView(){ return new WebView(this); }

I cant seem to get it to be behind everything else though. Am i doing something wrong?

my XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RR1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<LinearLayout
    android:id="@+id/LL1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <SurfaceView
        android:id="@+id/surfaceView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

</RelativeLayout>

my MainActivity:

package com.example.testfortim;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.Menu;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //SurfaceView sv = new SurfaceView();
    SurfaceView sv = (SurfaceView)findViewById(R.id.surfaceView1);
    sv.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            LinearLayout ll = (LinearLayout)findViewById(R.id.LL1);
            //LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)ll.getLayoutParams();
            //RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(ll.getLayoutParams().width/2,ll.getLayoutParams().height/2);//(RelativeLayout.LayoutParams)ll.getLayoutParams();
            RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
                    getWindowManager().getDefaultDisplay().getWidth()/2, 
                    getWindowManager().getDefaultDisplay().getHeight()/2
                    );
            rlp.setMargins(getWindowManager().getDefaultDisplay().getWidth()/2, getWindowManager().getDefaultDisplay().getHeight()/2, 0, 0);
            ll.setLayoutParams(rlp);

            WebView wv = makeWebView();
            //wv.setBackgroundColor(0);
            //wv.setBackgroundResource(R.color.Blue);
            //wv.setBackgroundResource(Color.BLUE);
            wv.loadData("<html><body>TEST</body></html>", "text/html", "utf-8");
            RelativeLayout rl = (RelativeLayout)findViewById(R.id.RR1);
            //rl.addView(wv);

            //ll.addView(wv);


        }

    });

}

protected WebView makeWebView() {
    return new WebView(this);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}

I resized the Linear Layout and moved that, so the Webview would need to be placed somewhere in RR1, from what i gather. I was looking at various documentation, and it either wasnt quite what iw as looking for or MAYBE by randomness, i just didnt grasp it.

Do you have ideas as to how this is accomplished?

As a sidenote: I have no idea why the onCreateOptionMenu method is there. I dont plan on using it, and will prolly end up removing it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:41:49+00:00Added an answer on June 15, 2026 at 7:41 pm

    Try rl.addView(wv, 0);
    will do the trick 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SurfaceView where I'm drawing a matrix (game board) and each cell
In my game, I have a surfaceView and I'm using a bitmap of resolution
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have an XML layout and want to add my own custom SurfaceView to
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have a SurfaceView that is resposible for drawing a Bitmap as a background
I currently have a SurfaceView that is in Landscape mode. Currently I am trying
HI! I have a surfaceView inside a horizontal scrollview that I want to fill
I have two images on a surfaceview and only one of the images is
I have an Application in that I want to capture video using Surfaceview and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.