Ayaz Alavi
Ayaz Alavi

Reputation: 4835

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

alt text

Upvotes: 5

Views: 10154

Answers (4)

Boy
Boy

Reputation: 7529

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>

Upvotes: 0

user756905
user756905

Reputation: 106

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.

Upvotes: 6

David Hedlund
David Hedlund

Reputation: 129832

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>

Upvotes: 10

Juhani
Juhani

Reputation: 5108

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"

Upvotes: 3

Related Questions