Android 创建类似 iphone 的渐变

发布于 2024-10-09 02:41:08 字数 133 浏览 0 评论 0原文

我需要在我的 Android 应用程序中创建类似黑色 iphone 的渐变。请查看下图中顶部的黑色渐变。怎么做呢?谢谢

alt text

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

魔法少女 2024-10-16 02:41:09

我知道这是一个老问题,但我一直在努力为想要在 Android 上复制 iPad 应用程序的客户获得同样的效果,这就是我想出的:

<?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>

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>
嗫嚅 2024-10-16 02:41:08

也许是这样的?

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <gradient
      android:startColor="#FF000000"
      android:endColor="#FF8E8E8E"
      android:angle="270"/>
</shape>

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>
鹤仙姿 2024-10-16 02:41:08

我发布了一篇关于 iPhone 和 Android 的博客:

http://www.dibbus.com/ 2011/06/android-gradient-toolbar/

您可以找到一些渐变示例以及使用 xml 和/或 9-pacth 图像的可能性。

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.

棒棒糖 2024-10-16 02:41:08

您可以在 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>

此示例是圆形渐变,但通过更改类型参数,您可以创建其他渐变。
将此代码包含在可绘制文件夹中的 xml 文件中,您可以在设置背景时引用该文件。 IE。 android:background="你的可绘制文件"

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文