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 8141569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:33:17+00:00 2026-06-06T12:33:17+00:00

I need the following xml to be made in code: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:gravity=right

  • 0

I need the following xml to be made in code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical" android:gravity="right"
            android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000"
            >
            <android.webkit.WebView android:layout_width="fill_parent"
            android:id="@+id/adview"
            android:scrollbars="none"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            ></android.webkit.WebView>
            <Button android:layout_width="wrap_content" android:text="x" android:textColor="#000000" 
            android:layout_height="wrap_content" android:id="@+id/hide_popup_button" android:background="#00000000" 
            android:layout_alignTop="@+id/adview" android:layout_alignParentRight="true"></Button>

        </RelativeLayout> 

I use the code below but I get a Force close:

RelativeLayout popwindow=new RelativeLayout(this);

        RelativeLayout.LayoutParams rl= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 50);
        popwindow.setLayoutParams(rl);
        WebView w= new WebView(this);
        w.setId(0X100);
        w.setScrollContainer(false);
        android.widget.RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)w.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        Button b=new Button(this);
        b.setId(0X101);
        b.setText("X");
        b.setBackgroundColor(Color.TRANSPARENT);
        b.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        android.widget.RelativeLayout.LayoutParams paramsbut = (RelativeLayout.LayoutParams)b.getLayoutParams();
        paramsbut.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        paramsbut.addRule(RelativeLayout.ALIGN_TOP,w.getId() );
        popwindow.addView(w,params);
        popwindow.addView(b,paramsbut);
        setContentView(popwindow);

I need suggestions on how to make that xml layout through java code.

  • 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-06T12:33:19+00:00Added an answer on June 6, 2026 at 12:33 pm

    You should post any exception you get in your question. See if this helps:

        RelativeLayout popwindow=new RelativeLayout(this);
        FrameLayout.LayoutParams rl= new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 50);
        popwindow.setLayoutParams(rl);
        WebView w= new WebView(this);
        w.setId(0X100);
        w.setScrollContainer(false);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, 50);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        w.setLayoutParams(params);
        Button b=new Button(this);
        b.setId(0X101);
        b.setText("X");
        b.setBackgroundColor(Color.TRANSPARENT);
        RelativeLayout.LayoutParams bparams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, ReloativeLayout.LayoutParams.WRAP_CONTENT);
        bparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        bparams.addRule(RelativeLayout.ALIGN_TOP, w.getId());
        b.setLayoutParams(bparams);        
        popwindow.addView(w);
        popwindow.addView(b);
        setContentView(popwindow);
    

    Custom component holding the WebView and the Button:

    public class CustomRelativeLayout extends RelativeLayout {
    
            private WebView mWebView;
            private Button mButton;
    
            public CustomRelativeLayout(Context context) {
                super(context);
                mWebView = new WebView(context);
                mWebView.setId(0X100);
                mWebView.setScrollContainer(false);
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.FILL_PARENT, 50);
                params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                mWebView.setLayoutParams(params);
                mButton = new Button(context);
                mButton.setId(0X101);
                mButton.setText("X");
                mButton.setBackgroundColor(Color.TRANSPARENT);
                RelativeLayout.LayoutParams bparams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT,
                        RelativeLayout.LayoutParams.WRAP_CONTENT);
                bparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                bparams.addRule(RelativeLayout.ALIGN_TOP, mWebView.getId());
                mButton.setLayoutParams(bparams);
                addView(mWebView);
                addView(mButton);
            }
    
            public WebView getTheWebView() {
                return mWebView;
            }
    
            public Button getTheButton() {
                return mButton;
            }
    
        }
    

    To use that component:

    CustomRelativeLayout popWindow = new CustomRelativeLayout(this);
        FrameLayout.LayoutParams rl= new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 50);
    setContentView(popWindow);
    // get a reference to the WebView and the Button
    WebView w = popWindow.getTheWebView();
    Button b = popWindow.getTheButton(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following preference screen in my app <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android> <EditTextPreference android:key=edittexvalue android:id=@+id/edittextvalue
I need to generate XML in the following form: <ns1:root xmlns:ns1=http://example.com/xmlns1 xmlns:ns2=http://example.com/xmlns2> <ns2:item ns2:param=value
I have the following XML <?xml version=1.0?> <FileHeader xmlns=urn:schemas-ncr-com:ECPIX:CXF:FileStructure:020001 VersionNumber=020001 TestFileIndicator=P CreationDate=13012009 CreationTime=172852 FileID=0000000001
I need to generate the following XML: <Learner xmlns=some.domain.api> <ActivationDate>1999-05-31T11:20:00</ActivationDate> <EmailAddress>String content</EmailAddress> <ExpirationDate>1999-05-31T11:20:00</ExpirationDate> <FederalId>String
I'm trying to write a Linq2XML query to query the following XML. I need
Where do I include the Upgrade/Target Image in the following Patch XML? I need
I need to deserialize a XML file to a object. Following is the XML
I need to parse the following xml document (which is coming from external web
I need to group the following XML doc to show: Parent Item Qty ----------------------------------
I have the following XML I need to parse. Much of my issue seems

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.