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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:37:51+00:00 2026-05-27T19:37:51+00:00

is it possible to use a url to set background for framelayout ? Example:

  • 0

is it possible to use a url to set background for framelayout?

Example:
i want to use the URL like this as my framelayout background.

what i really want to achieve is that when my activity loads it will fetch the image from my domain and use it as my framelayout background image. i was able to do this but i used a imageview and a button.

below is the code that i use:

public class MyAppActivity extends Activity {

ImageView imView;
    String imageUrl= "http://www.mydomain.com/resource/images/";

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);
Button bt3= (Button)findViewById(R.id.postbutton);
bt3.setOnClickListener(getImgListener);

}
View.OnClickListener getImgListener = new View.OnClickListener()
{

      public void onClick(View view) {

           downloadFile(imageUrl+"image"+".png");
           Log.i("im url",imageUrl+"image"+".png");
      }

};


Bitmap bmImg;
void downloadFile(String fileUrl){
      URL myFileUrl =null;          
      try {
           myFileUrl= new URL(fileUrl);
      } catch (MalformedURLException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
      }
      try {
           HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
           conn.setDoInput(true);
           conn.connect();
           InputStream is = conn.getInputStream();

           bmImg = BitmapFactory.decodeStream(is);
           imView.setImageBitmap(bmImg);
      } catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
      }
 }

 }

and here is my XML codes:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/rakistaradiobg"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="98dp"
    android:layout_gravity="bottom|center"
    android:scaleType="fitXY"
    android:src="@drawable/btnbg" />

<Button
    android:id="@+id/postbutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:text="Button" />

  • 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-05-27T19:37:52+00:00Added an answer on May 27, 2026 at 7:37 pm

    Something interested, (I never try this but it should work)

    FrameLayout fm = (FrameLayout)findViewById(R.id.FrameLayout01);      
    Drawable drw = ImageOperations(this,url,filename)
    fm.setBackgroundDrawable(drw)
    

    Convert your image url in Drawable using

    private Drawable ImageOperations(Context ctx, String url, String saveFilename) {
            try {
                InputStream is = (InputStream) this.fetch(url);
                Drawable d = Drawable.createFromStream(is, saveFilename);
                return d;
            } catch (MalformedURLException e) {
                e.printStackTrace();
                return null;
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    
        public Object fetch(String address) throws MalformedURLException,IOException {
            URL url = new URL(address);
            Object content = url.getContent();
            return content;
        }
    

    Try this and let me know what happen..

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

Sidebar

Related Questions

is it possible to use GET or something like this to load a record
Is it possible to use more complicated layer url rule matching syntax? I want
Is is possible to use Tuckey's URL Rewrite to rewrite to a different Tomcat
Is it possible to use gcov for coverage testing of multi-threaded applications? I've set
I have the following problem: I use a script that saves the referer URL.
I have user preference (colour, locale settings) on example.com that I would like to
I have a set of search filters that set a URL string (for further
I want to use java.net.url to crawl some websites and retrieve some data. I
Is it possible use mod_rewrite to resolve addresses hosted on another server? Say I
I have recently started looking into Google Charts API for possible use within the

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.