I need to create black iphone like gradient in my android application. Please view black gradient at the top i开发者_如何学运维n 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>
精彩评论