android holo theme background - android

I would like to know, if I can get the background that is displayed when using android's holo theme, as a drawable? (you know, the dark black and blue background that is displayed for 3.0+) I need to use it as a drawable, so if someone knows if this can be done, please let me know..
Sorry, but I forgot to mention that this is displayed on a tablet device, not sure about phones.

Location of the files
Holo-Dark:
/path_to_sdk/platforms/android-version/data/res/drawable/background_holo_dark.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ff000000"
android:endColor="#ff272d33"
android:angle="270" />
</shape>
Holo-Light:
/path_to_sdk/platforms/android-version/data/res/drawable/background_holo_light.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#ffe8e8e8"
android:endColor="#ffffffff"
android:angle="270" />
</shape>
Make your own
Put the following code in res/drawable/background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
>
<gradient
android:angle="270"
android:startColor="#ff020202"
android:endColor="#ff272D33"
android:type="linear" />
</shape>
Add the background reference to your parent viewgroup
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background">
Play around with the values until you get the desired effect.

If it is possible, your best bet is to look in the android .jar for 3.0 (which can be downloaded using ADT in Eclipse)
The image may be found in /drawable/drawable-hdpi or possibly somewhere within /drawable
If not, it likely is only possible to find in the source.

Here, perhaps this would help: http://developer.android.com/guide/topics/ui/themes.html

Related

Android transparent property does not work on Android 4.1.1

Im trying to make transparent Buttons and editTexts, I'm using a custom xml file, it works on Android 5 as expected (all fields are indeed transparent), but when running the same app on the emulator using Android 4.1.1, these fields appear black.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:background="#android:color/transparent">
<stroke android:width="3px" android:color="#FFF" />
</shape>
How can the transparency effect be achieved on older android OS's?
Setting background as transparent is working api level 4.0 onwards add below line in your xml
android:background="#android:color/transparent"
or Try some thing like this
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#android:color/transparent" />
<stroke android:width="3px" android:color="#FFF" />
</shape>
Add a color property to your shape tag:
<solid android:color="#android:color/transparent" />
Try defining the transparent colour yourself, just to be sure it's not a framework thing.
<color name="transparent">#00000000</color>
Transparency definitely works on Jelly Bean, so I suspect it could be the emulator.

Creating a custom round button in android

Can anyone help me out here. I am trying to create a small round button that would represent a lottery ball using a very simple self created XML class round_button.xml. However I keep getting the error over and over even when Ive put the code through a w3schools validator that " Error parsing XML: junk after document element." I cannot see what the issue is here and maybe I am missing something very clear, I dont know. Could anyone please help me out. Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" />
<solid
android:color="#FF0000"
</shape>
You are just missing a bit of concept of closing the tags. You have extra / over android:shape="oval" />. You are already closing the tag at the end with </shape> so no need to use />.
Secondly you haven't ended <solid tag with />. So try something like:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid
android:color="#FF0000" />
</shape>
You messed up tags. You have closed shape before end and not closed solid tag.
Try this one.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
>
<solid android:color="#FF0000" />
</shape>

SlidingPaneLayout.setShadowResource Android

I'm developing a APP with a Sliding Pane and works correctly, but I dont know how I can put a shadow like Hangouts Google APP.
It's a bit hard to explain, see this:
Im trying to use setShadowResource, but I dont know how to design the shadow in nine patch.
Thanks for the help!
EDIT:
I'm trying to create a shadow using a shape with gradient, but dont works :|
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:centerColor="#8B0000"
android:endColor="#34FFDD"
android:startColor="#FF00FF" />
</shape>
Activity:
mPanes.openPane();
mPanes.setShadowResource(R.drawable.es_slidingpane_shadow);
mPanes.setSliderFadeColor(Color.parseColor("#FFFFFF"));
you need to set width and height to your drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:centerColor="#8B0000"
android:endColor="#34FFDD"
android:startColor="#FF00FF" />
<size android:width="5.0dp" android:height="0.5dp" />
</shape>

Android: Is it possible to scale a xml drawable?

Here is what I want to do: I have this scale xml:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/mydrawable"
android:scaleGravity="bottom"
android:scaleHeight="50%" />
And I want to use it with this drawable xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FFFFFFFF"
android:endColor="#FFFF0000"
android:angle="90" />
</shape>
</item>
</layer-list>
Then I set the scale xml as a background for a LinearLayout, but I don't see anything. Am I missing something or is it not possible to do this (with XML)?
This is an issue with the ScaleDrawable object which cannot be resolved in XML.
But it is easy, just do the following:
// Get the scale drawable from your resources
ScaleDrawable scaleDraw = (ScaleDrawable)getResources().getDrawable(R.drawable.background_scale);
// set the Level to 1 (or anything higher than 0)
scaleDraw.setLevel(1);
// Now assign the drawable where you need it
layout.setBackgroundDrawable(scaleDraw);
I tested your code using this solution and it worked fine.

Android create iphone-like Gradient

I need to create black iphone like gradient in my android application. Please view black gradient at the top in the image below. How to do it? Thanks
Something like this, perhaps?
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#FF000000"
android:endColor="#FF8E8E8E"
android:angle="270"/>
</shape>
I've posted a blog about an Iphone look an Android:
http://www.dibbus.com/2011/06/android-gradient-toolbar/
You can find some examples of gradients and what is possible using xml and/or 9-pacth images.
You can create gradients in XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="radial" android:gradientRadius="400"
android:startColor="#88cce7" android:endColor="#075e81"/>
</shape>
This example is a round gradient but by changing type param you can create others.
Include this code in a xml file in your drawable folder and you can refer to that file when you set a background. ie. android:background="your drawable file"
I know this is an old question, but I was messing around to get this same effect for a customer who wants a copy of his iPad app on Android, this is what I came up with:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:centerColor="#FF333333"
android:centerY="2%"
android:endColor="#FF000000"
android:startColor="#FF8E8E8E" />
<corners android:radius="5dp" />
</shape>

Categories

Resources