1

I have a XML file that I set up to tell the app what image to use as the splash screen. However, I have multiple images that can be used depending on the screen size. I have the following code to determine the screen size:

Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); 

Note: I'm using getWidth and getHeight because my app is using API 7. I do know that they were deprecated later on.

Anyways, here is what I have in my XML file:

<?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.Splash" parent="android:Theme"> <item name="android:windowBackground">@drawable/splash_screen</item> <item name="android:windowNoTitle">true</item> </style> </resources> 

Basically, what I want to be able to do is be able to programmatically change splash_screen to whatever the name of my file is depending on the screen size. Any ideas how I can change the XML file from my code?

Thanks in advance for any help given.

2
  • You haven't specified what language and what platform. Commented Feb 24, 2012 at 6:29
  • Language? I'm assuming you mean programming language. It's an android application so Java. Commented Feb 24, 2012 at 6:41

2 Answers 2

3

You don't have to do it manually. Resource qualifiers do this for you, so you can always refer to a resource by a single name. Check the information and examples available at http://developer.android.com/guide/practices/screens_support.html.

Sign up to request clarification or add additional context in comments.

Comments

-1

If this is in your resources, you CANNOT modify your resources at run time. Only thing you can do is programatically build your layout/styles.

3 Comments

The attribute I want to change is located within the resources element. The XML file itself is located within res/values
which I just said you CANNOT modify your resources. Read above.
When asking the question, I was unsure exactly what I was trying to ask. The resource qualifiers that dtmilano pointed out was what I was thinking of at the time I asked my question. I apologize for asking the question incorrectly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.