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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:28:34+00:00 2026-06-05T07:28:34+00:00

I have an android app with an background image. My goal is to create

  • 0

I have an android app with an background image. My goal is to create 3 or 4 background images and give the possibility to the user to change the background.

Actually, I have 4 images named bg1.png, bg2.png, bg3.png and bg4.png.
I have think about something to declare an string value “background ” in Strings.xml with the name of the image. The name of the background image will allways be take from the background string and when the users will change the background, this wil change only the value of the string background.

Is this idea good or is there something easyer?
How could I set the background of my layout in the xml layout file with the “background” string’s value ? Shuld i do this programatically?

Thank you.

  • 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-05T07:28:35+00:00Added an answer on June 5, 2026 at 7:28 am

    I think if you want to change the background to the activity layout, you can do it using setBackground method for the Layout for example:

    activityLayout = (LinearLayout)findViewById(R.id.tableLayout1);
    activityLayout.setBackgroundDrawable(getResources().getDrawable(R.id.somedrawable))
    

    You can store the background image using for example SharedPreference, then when you launch an activity you read the preference that contains the background. For example when the user choice the background:

    SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
    SharedPreferences.Editor prefsEditor = myPrefs.edit();
    prefEditor.putInt("backgroudResourceId", userchoice);
    prefEditor.commit();
    

    And when an activity start, you must read the resourceId from the SharedPreference:

    SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
    drawableid = myPrefs.getInt("backgroundResourceId", defaultvalue); 
    yourlayout.setBackground(drawableid);
    

    where defaultvalue is the default value if the preference is not set. yourLayout is supposed to be initialized (in the same way of activity layout).

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

Sidebar

Related Questions

In my android app I have a background image which is longer than the
I should like to have an android app which has its background image on
I have an android app which gives the user the option of loading a
I have set a background image in my app, but the background image is
I have this code in my app.js file in android and an images folder
I am building an android app in which I have to add a background
In my app i have to set up a small image as background, to
I have created a background image from my app, and adding a copy of
I have android app . i should pass the data from android to web
We have an Android app and a Web Service. We want to download part

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.