ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Android 新拟态UI (Neumorphism)

2021-02-23 09:29:41  阅读:658  来源: 互联网

标签:License distributed UI 16dp under Neumorphism Android 拟态


前言

本文转自github,只是进行了图片的处理和部分翻译,已获作者授权
截至首次发文前找到的原作者的文章地址-May,17,2020若找到本文章更新的时间节点,请私信我更新。
原作者github地址
文末附源码下载地址,免费。
在这里插入图片描述

Android上的拟态化UI


This is the experimental codes to build Neumorphism designs in Android.
Not a library. Just sample project now(目前只是示例项目).


Preview

Light | Dark

添加依赖

在项目级 build.gradle 添加以下依赖:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

然后, 在 build.gradle中添加以下依赖

dependencies {
//截至首次发文前latest_version为0.3.0
    implementation 'com.github.fornewid:neumorphism:{latest_version}'
}

Features

  • 为组件绘制阴影实现新拟态化效果。
    支持以下组件:
    • ViewGroup: CardView
    • View: Button, FloatingActionButton, ImageView
  • 在Text上绘制阴影来实现TextView的新拟态化。

如果您需要更多功能或要修复错误,请单击 new issue并报告给我!

示例

<soup.neumorphism.NeumorphCardView
    // 预定义样式
    style="@style/Widget.Neumorph.CardView"

    // 设置elevation和color
    app:neumorph_shadowElevation="6dp"
    app:neumorph_shadowColorLight="@color/solid_light_color"
    app:neumorph_shadowColorDark="@color/solid_dark_color"

    // 设置光源 lightSource
    app:neumorph_lightSource="leftTop|leftBottom|rightTop|rightBottom"

    // 设置Shape类型和corner size
    app:neumorph_shapeType="{flat|pressed|basin}"
    app:neumorph_shapeAppearance="@style/CustomShapeAppearance"

    // 设置 background 或 stroke
    app:neumorph_backgroundColor="@color/background_color"
    app:neumorph_strokeColor="@color/stroke_color"
    app:neumorph_strokeWidth="@dimen/stroke_width"

使用插图以避免修剪阴影
    // 使用 inset 以避免阴影被裁剪. (default=12dp)
    app:neumorph_inset="12dp"
    app:neumorph_insetStart="12dp"
    app:neumorph_insetEnd="12dp"
    app:neumorph_insetTop="12dp"
    app:neumorph_insetBottom="12dp"

    // Use a padding. (default=12dp)
    android:padding="12dp">

    <!-- NeumorphCardView extends FrameLayout. So you can wrap childrens like this. -->
    <ConstraintLayout />
</soup.neumorphism.NeumorphCardView>

<style name="CustomShapeAppearance">
    <item name="neumorph_cornerFamily">{rounded|oval}</item>
    <item name="neumorph_cornerSize">32dp</item>

    <!-- Or if wants different radii depending on the corner. -->
    <item name="neumorph_cornerSizeTopLeft">16dp</item>
    <item name="neumorph_cornerSizeTopRight">16dp</item>
    <item name="neumorph_cornerSizeBottomLeft">16dp</item>
    <item name="neumorph_cornerSizeBottomRight">16dp</item>
</style>
  • 光源(LightSource)

LEFT_TOPLEFT_BOTTOMRIGHT_TOPRIGHT_BOTTOM
  • 阴影类型(ShapeType)

FLATPRESSEDBASIN

License

Copyright 2020 SOUP

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

GitHub源码下载地址

标签:License,distributed,UI,16dp,under,Neumorphism,Android,拟态
来源: https://blog.csdn.net/qq_17282141/article/details/113945103

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有