Android create iphone-like Gradient

人盡茶涼 提交于 2019-12-22 07:46:32

问题


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


回答1:


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>



回答2:


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.




回答3:


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"




回答4:


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>


来源:https://stackoverflow.com/questions/4510585/android-create-iphone-like-gradient

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!