Shape 支持在布局中直接定义啦

Related tags

GUI ShapeView
Overview

Shape 框架

集成步骤

  • 在项目根目录下的 build.gradle 文件中加入
buildscript {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
  • 在项目 app 模块下的 build.gradle 文件中加入
android {
    // 支持 JDK 1.8
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    // Shape 框架:https://github.com/getActivity/ShapeView
    implementation 'com.github.getActivity:ShapeView:2.0'
}

AndroidX

  • 如果项目是基于 AndroidX 包,请在项目 gradle.properties 文件中加入
# 表示将第三方库迁移到 AndroidX
android.enableJetifier = true
  • 如果项目是基于 Support 包则不需要加入此配置

框架文档

<resources>

    <!-- Shape 形状(默认是矩形) -->
    <attr name="shape">
        <!-- 矩形 -->
        <enum name="rectangle" value="0" />
        <!-- 椭圆形 -->
        <enum name="oval" value="1" />
        <!-- 线条 -->
        <enum name="line" value="2" />
        <!-- 圆环(不支持动态设置,请自定义 xml 来完成需求) -->
        <!--<enum name="ring" value="3" />-->
    </attr>
    <!-- Shape 宽度 -->
    <attr name="shape_width" format="dimension" />
    <!-- Shape 高度 -->
    <attr name="shape_height" format="dimension" />

    <!-- 填充色 -->
    <attr name="shape_solidColor" format="color|reference" />
    <!-- 圆角大小 -->
    <attr name="shape_radius" format="dimension" />
    <!-- 左上角的圆角大小 -->
    <attr name="shape_topLeftRadius" format="dimension" />
    <!-- 右下角的圆角大小 -->
    <attr name="shape_topRightRadius" format="dimension" />
    <!-- 左下角的圆角大小 -->
    <attr name="shape_bottomLeftRadius" format="dimension" />
    <!-- 右下角的圆角大小 -->
    <attr name="shape_bottomRightRadius" format="dimension" />

    <!-- 渐变色起始颜色 -->
    <attr name="shape_startColor" format="color" />
    <!-- 渐变色中间颜色(可不设置) -->
    <attr name="shape_centerColor" format="color" />
    <!-- 渐变色结束颜色 -->
    <attr name="shape_endColor" format="color" />
    <!-- 是否将用于缩放渐变 -->
    <attr name="shape_useLevel" format="boolean" />
    <!-- 渐变角度(仅用于线性渐变。必须是 0-315 范围内的值,并且是 45 的倍数) -->
    <attr name="shape_angle" format="float" />
    <!-- 渐变类型(默认类型是线性渐变) -->
    <attr name="shape_gradientType">
        <!-- 线性渐变 -->
        <enum name="linear" value="0" />
        <!-- 径向渐变 -->
        <enum name="radial" value="1" />
        <!-- 扫描渐变 -->
        <enum name="sweep"  value="2" />
    </attr>
    <!-- 渐变中心 X 点坐标的相对位置(默认值为 0.5)-->
    <attr name="shape_centerX" format="float|fraction" />
    <!-- 渐变中心 Y 点坐标的相对位置(默认值为 0.5)-->
    <attr name="shape_centerY" format="float|fraction" />
    <!-- 渐变色半径(仅用于径向渐变) -->
    <attr name="shape_gradientRadius" format="float|fraction|dimension" />

    <!-- 边框颜色 -->
    <attr name="shape_strokeColor" format="color|reference" />
    <!-- 边框宽度 -->
    <attr name="shape_strokeWidth" format="dimension" />
    <!-- 边框虚线宽度(为 0 就是实线,大于 0 就是虚线) -->
    <attr name="shape_dashWidth" format="dimension" />
    <!-- 边框虚线间隔(虚线与虚线之间的间隔) -->
    <attr name="shape_dashGap" format="dimension" />

</resources>

使用案例

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="矩形实线边框内部无填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="矩形虚线边框内部无填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_dashGap="5dp"
    app:shape_dashWidth="10dp"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="矩形实线边框-内部填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_solidColor="#ff00ffff"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="矩形虚线边框-内部填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_dashGap="5dp"
    app:shape_dashWidth="10dp"
    app:shape_solidColor="#ff00ffff"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-只有边框"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_radius="5dp"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-只有内部填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_radius="5dp"
    app:shape_solidColor="#8000ff00" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-有边框有填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_radius="5dp"
    app:shape_solidColor="#8000ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-左边圆角为一个半圆弧"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_bottomLeftRadius="20dp"
    app:shape_solidColor="#8000ff00"
    app:shape_topLeftRadius="20dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-左右两边都是半圆弧"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_radius="20dp"
    app:shape_solidColor="#8000ff00" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆角矩形-左右两边都是半圆弧-带边框"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_radius="20dp"
    app:shape_solidColor="#8000ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="垂直线性渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_angle="-45"
    app:shape_centerColor="#8000ff00"
    app:shape_centerX="0.5"
    app:shape_centerY="0.4"
    app:shape_endColor="#1000ff00"
    app:shape_startColor="#ff00ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="水平线性渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_angle="0"
    app:shape_centerColor="#8000ff00"
    app:shape_centerX="0.5"
    app:shape_centerY="0.5"
    app:shape_endColor="#ff00ff00"
    app:shape_startColor="#1000ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="对角线线性渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_angle="45"
    app:shape_centerColor="#8000ff00"
    app:shape_centerX="0.5"
    app:shape_centerY="0.5"
    app:shape_endColor="#1000ff00"
    app:shape_startColor="#ff00ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="径向渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_angle="0"
    app:shape_centerX="0.5"
    app:shape_centerY="0.5"
    app:shape_endColor="#ff00ff00"
    app:shape_gradientRadius="20dp"
    app:shape_gradientType="radial"
    app:shape_startColor="#0000ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="扫描渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="rectangle"
    app:shape_angle="0"
    app:shape_centerX="0.5"
    app:shape_centerY="0.5"
    app:shape_gradientType="sweep"
    app:shape_startColor="#ff00ff00"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆-边框"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆-填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_solidColor="#800000ff" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="圆-边框填充"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_solidColor="#800000ff"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="线性渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_angle="-90"
    app:shape_centerColor="#80ff0000"
    app:shape_centerX="0.5"
    app:shape_centerY="0.8"
    app:shape_endColor="#ffff0000"
    app:shape_gradientType="linear"
    app:shape_startColor="#00ff0000" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="径向渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_centerColor="#80ff0000"
    app:shape_centerX="0.5"
    app:shape_centerY="0.5"
    app:shape_endColor="#10ff0000"
    app:shape_gradientRadius="80dp"
    app:shape_gradientType="radial"
    app:shape_startColor="#ffff0000" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="扫描渐变"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="oval"
    app:shape_centerColor="#80ff0000"
    app:shape_centerX="0.5"
    app:shape_centerY="0.6"
    app:shape_endColor="#20ff0000"
    app:shape_gradientRadius="20dp"
    app:shape_gradientType="sweep"
    app:shape_startColor="#ffff0000" />

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="实线"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="line"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp"/>

<com.hjq.shape.view.ShapeTextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:gravity="center"
    android:padding="10dp"
    android:text="虚线"
    android:textColor="@android:color/black"
    android:textSize="14sp"
    app:shape="line"
    app:shape_dashGap="5dp"
    app:shape_dashWidth="10dp"
    app:shape_strokeColor="#ffff0000"
    app:shape_strokeWidth="1dp"/>
  • 目前支持的控件有:

    • View:ShapeView、ShapeTextView、ShapeButton、ShapeImageView、ShapeRadioButton、ShapeCheckBox、ShapeEditText

    • Layout:ShapeLinearLayout、ShapeFrameLayout、ShapeRelativeLayout、ShapeConstraintLayout、ShapeRecyclerView

框架亮点

  • 更加便捷:无需新增 Xml 文件,直接定义控件属性即可

  • 即时生效:在布局中可实时预览效果,即见所得

  • 无学习成本:控件属性和原生 Shape 命名保持一致,无需额外学习

  • 覆盖范围广:几乎涵盖所有常见的 View 控件,并且控件名称无任何记忆成本

作者的其他开源项目

微信公众号:Android轮子哥

Android 技术分享 QQ 群:78797078

如果您觉得我的开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 🐵 就太 👍 了。您的支持将鼓励我继续创作:octocat:

点击查看捐赠列表

License

Copyright 2021 Huang JinQun

Licensed 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.
Comments
  • 在小屏尺寸的屏幕的适配上面有问题

    在小屏尺寸的屏幕的适配上面有问题

    问题描述 框架版本【必填】: com.github.getActivity:ShapeView:8.5

    问题描述【必填】:在小屏手机上超过一屏幕的内容就不显示线性布局;

    复现步骤【必填】:可以测试一下不同小屏幕的机型

    是否必现【必填】:是

    出现问题的手机信息【必填】:小米6、vivo Y67

    出现问题的安卓版本【必填】:安卓6.0

    问题信息的来源渠道【必填】:自己项目开发过程中遇到的bug

    请回答 是部分机型还是所有机型都会出现【必答】:部分机型 小米6

    框架最新的版本是否存在这个问题【必答】:是

    是否已经查阅框架文档还未能解决的【必答】:是

    issue 是否有人曾提过类似的问题【必答】:否

    是否可以通过 Demo 来复现该问题【必答】:是

    来实现是否也会出现该问题【必答】:否

    其他 提供报错堆栈(如果有报错的话必填,注意不要拿被混淆过的代码堆栈上来)

    提供截图或视频(根据需要提供,此项不强制) 下面有截图

    提供解决方案(如果已经解决了的话,此项不强制)

    opened by TianTingting 11
  • ShapeImageView不能同时设置stroke和shadow

    ShapeImageView不能同时设置stroke和shadow

     <com.hjq.shape.view.ShapeImageView
          android:layout_width="86dp"
          android:layout_height="86dp"
          android:layout_gravity="center"
          android:padding="8dp"
          android:src="@drawable/blank_img"
          app:shape_radius="8dp"
          app:shape_solidColor="#1Affffff"
          app:shape_shadowSize="30dp"
          app:shape_shadowColor="#45FFDC78"
          app:shape_strokeColor="#FEDF65"
          app:shape_strokeWidth="2dp" />
    

    这样 stroke就会消失,去掉shadow的配置就能显示stroke。 目前只有单独加了一层ShapeView做的shadow

    opened by xxxifan 8
  • 设置 solidColor 颜色后,如何动态 删除solidColor 设置呢

    设置 solidColor 颜色后,如何动态 删除solidColor 设置呢

    设置 solidColor 颜色后,如何动态 删除solidColor 设置呢

    • 框架版本【必填】:v8.3

    • 问题描述【必填】:有个需求选中时设置了 solidColor,想取消选中时,删除 solidColor,不知道使用哪个api 删除

    • 复现步骤【必填】:列表 点击

    • 是否必现【必填】:是

    • 出现问题的手机信息【必填】:所有手机

    • 出现问题的安卓版本【必填】:所有版本

    bug 
    opened by tianshaokai 7
  • 使用阴影和不使用阴影的view大小不一致

    使用阴影和不使用阴影的view大小不一致

    问题描述

    • 框架版本【必填】:8.2

    • 问题描述【必填】:使用阴影和不使用阴影的view大小不一致框架的阴影很方便 但是在开发中遇到一个,比如一个view是宽180dp高200dp UI图上是20dp的阴影宽度 所以我在写布局的时候 高宽各加了 阴影宽度x2 ,但实际效果出来 不用阴影的180dp 200dp画出来的view 比用阴影180dp+ 20x2 200dp+20x2 画出来的要大一些,我想确认在用阴影的时候是不是我这样去计算增加view的高宽,理论上这样计算阴影的view画出来的应该和不带阴影的是一个大小,我指的是不含阴影处

    • 复现步骤【必填】:XXX

    • 是否必现【必填】:是

    • 出现问题的手机信息【必填】:小米10

    • 出现问题的安卓版本【必填】:12

    请回答

    • 是部分机型还是所有机型都会出现【必答】:全部

    • 框架最新的版本是否存在这个问题【必答】:是

    • 是否已经查阅框架文档还未能解决的【必答】:是

    • issue 是否有人曾提过类似的问题【必答】:是)

    • 是否可以通过 Demo 来复现该问题【必答】:是

    • 使用原生的 shape.xml 来实现是否也会出现该问题【必答】:否

    其他

    • 提供报错堆栈(如果有报错的话必填,注意不要拿被混淆过的代码堆栈上来)

    • 提供截图或视频(根据需要提供,此项不强制)

    image image

    • 提供解决方案(如果已经解决了的话,此项不强制)
    bug 
    opened by sdjwj1118 7
  • implementation ShapeView后,编译出现AAPT错误。

    implementation ShapeView后,编译出现AAPT错误。

    我的工程只要添加ShapeView库,编译出现以下出错,不得解:

    xxx\src\main\res\values\strings.xml:1238:5-115: AAPT: warn: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?.

    去除ShapeView即编译正常。

    opened by eagle518 7
  •  Check属性问题

    Check属性问题

    【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】

    建议收集

    • issue 是否有人曾提过类似的问题?【必答】(一旦出现重复提问我将不会再次解答) 没有
    • 框架文档是否有提及到此问题?【必答】:是/否(请先看完框架的文档后再来提建议) 没有
    • 你觉得框架有什么不足之处?【必答】(你可以描述框架有什么令你不满意的地方) ShapeCheckBox 或者 ShapeRadioButton 希望加个属性默认不需要图标。或者Shapetextview 支持 Check属性,目前测试下来是不支持的
    • 你觉得该怎么去完善会比较好?【非必答】(你可以提供一下自己的想法或者做法供作者参考)
    help wanted 
    opened by 287138531 6
  • 使用ShapeConstraintLayout 以及 ShapeView 设置阴影的时候 阴影区域会全黑

    使用ShapeConstraintLayout 以及 ShapeView 设置阴影的时候 阴影区域会全黑

    问题描述

    • 框架版本【必填】:8.2

    • 问题描述【必填】:使用ShapeConstraintLayout 以及 ShapeView 设置阴影的时候 阴影区域会全黑

    • 复现步骤【必填】:XXX

    • 是否必现【必填】:是

    • 出现问题的手机信息【必填】:OPPO R11s 2017年11月份发布的手机 也确实有点老了 但是还能做调试机

    • 出现问题的安卓版本【必填】:8.1.0

    请回答

    • 是部分机型还是所有机型都会出现【必答】:部分 目前仅OPPO R11s 但不确定OPPO其他机型有没有问题

    • 框架最新的版本是否存在这个问题【必答】:是

    • 是否已经查阅框架文档还未能解决的【必答】:是

    • issue 是否有人曾提过类似的问题【必答】:否

    • 是否可以通过 Demo 来复现该问题【必答】:是

    • 使用原生的 shape.xml 来实现是否也会出现该问题【必答】:否

    其他

    • 提供截图或视频(根据需要提供,此项不强制)
                <com.hjq.shape.layout.ShapeConstraintLayout
                    android:layout_width="match_parent"
                    android:id="@+id/cl_test"
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="10dp"
                    app:shape_shadowSize="6dp"
                    app:shape_shadowColor="@color/shadowColor"
                    app:shape_solidColor="@color/white"
                    app:layout_constraintTop_toBottomOf="@id/cl_top"
                    android:layout_height="100dp"/>
    

    1657177160717

    图片是真机通过scrcpy接到电脑的 不是模拟器 是真机调试

    • 提供解决方案(如果已经解决了的话,此项不强制) !!! 不是解决方案 但是发现 只需要加上 一点点圆角 哪怕是1dp 阴影就正常了 但是圆角也存在了 还是有些小问题 image 通过android studio 预览直接就能看到 黑边 加上1dp的圆角 黑边马上就消失了 可能跟oppo的系统也没多大关系
    bug 
    opened by wangyichn66 6
  • 设置了背景线性渐变后,阴影效果就会失效了?这是互斥的原因吗?

    设置了背景线性渐变后,阴影效果就会失效了?这是互斥的原因吗?

    代码如下 <com.hjq.shape.view.ShapeTextView android:layout_width="match_parent" android:layout_height="200dp" android:layout_margin="10dp" android:gravity="center" android:padding="10dp" android:text="垂直线性渐变" android:textColor="@android:color/black" android:textSize="14sp" app:shape="rectangle" app:shape_angle="90" app:shape_endColor="#ffdff8f0" app:shape_startColor="#fff7fefe" app:shape_shadowSize="9dp" app:shape_shadowColor="#50000000" app:shape_shadowOffsetX="5dp" app:shape_shadowOffsetY="5dp" app:shape_topLeftRadius="12dp" app:shape_topRightRadius="12dp" app:shape_bottomRightRadius="12dp" app:shape_bottomLeftRadius="0dp" />

    opened by kanfRUI 6
  • 在不同机型上面适配有问题

    在不同机型上面适配有问题

    【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】

    问题描述

    • 框架版本【必填】: com.github.getActivity:ShapeView:8.5

    • 问题描述【必填】:在oppo 手机上面机型是安卓12 跟设计图符合度比较高,在华为荣耀8 上面跟设计图出入比较大,不同机型表现的不一样。

    • 复现步骤【必填】:可以测试一下不同机型

    • 是否必现【必填】:是

    • 出现问题的手机信息【必填】:华为荣耀8

    • 出现问题的安卓版本【必填】:安卓8.0

    • 问题信息的来源渠道【必填】:自己项目开发过程中遇到的bug

    请回答

    • 是部分机型还是所有机型都会出现【必答】:部分机型 华为荣耀8

    • 框架最新的版本是否存在这个问题【必答】:是

    • 是否已经查阅框架文档还未能解决的【必答】:是

    • issue 是否有人曾提过类似的问题【必答】:否

    • 是否可以通过 Demo 来复现该问题【必答】:下面有代码

    • 使用原生的 shape.xml

    来实现是否也会出现该问题【必答】:否

    其他

    • 提供报错堆栈(如果有报错的话必填,注意不要拿被混淆过的代码堆栈上来)

    • 提供截图或视频(根据需要提供,此项不强制) 下面有截图

    • 提供解决方案(如果已经解决了的话,此项不强制)

    bug 
    opened by Mrliandroid 5
  • 设置的渐变方向无效

    设置的渐变方向无效

    【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】

    问题描述

    • 框架版本【必填】:8.5

    • 问题描述【必填】:设置为垂直渐变,但显示出来始终是水平方向的渐变

                        <com.hjq.shape.layout.ShapeRelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="@dimen/dp_250"
                            app:shape_textGradientOrientation="vertical"
                            app:shape_endColor="@color/white"
                            app:shape_startColor="@color/fill_2_color"
                            />
      

    请回答

    • 是部分机型还是所有机型都会出现【必答】:只测试了华为Mata 40

    • 框架最新的版本是否存在这个问题【必答】:最新

    • 是否已经查阅框架文档还未能解决的【必答】:是

    • issue 是否有人曾提过类似的问题【必答】:是/否(看看曾经有人提过类似的问题,先参考一下别人是怎么解决的)

    • 是否可以通过 Demo 来复现该问题【必答】:是/否(排查一下是不是自己的项目代码写得有问题导致的)

    • 使用原生的 shape.xml 来实现是否也会出现该问题【必答】:是/否(排查一下是不是框架的代码存在问题导致的)

    其他

    • 提供报错堆栈(如果有报错的话必填,注意不要拿被混淆过的代码堆栈上来)

    • 提供截图或视频(根据需要提供,此项不强制)

    • 提供解决方案(如果已经解决了的话,此项不强制)

    bug 
    opened by 979881765 5
  • 使用ShapeRelativeLayout的时候给布局设置宽度为wrap_content minWidth=

    使用ShapeRelativeLayout的时候给布局设置宽度为wrap_content minWidth="60dp" 通过代码修改该布局的setStrokeWidth和setStrokeColor 布局宽度会直接撑满

    【警告:请务必按照 issue 模板填写,不要抱有侥幸心理,一旦发现 issue 没有按照模板认真填写,一律直接关闭】

    问题描述

    • 框架版本【必填】:8.3

    • 问题描述【必填】:使用ShapeRelativeLayout的时候给布局设置宽度为wrap_content minWidth="60dp" 通过代码修改该布局的setStrokeWidth和setStrokeColor 布局宽度会直接撑满

    • 复现步骤【必填】:给ShapeRelativeLayout设置最小宽度 再通过代码修改边框和(注意:目前不受理没有复现步骤的 Bug 单)

    • 是否必现【必填】:填是/否 是

    • 出现问题的手机信息【必填】:请填写出现问题的品牌和机型 小米10u

    • 出现问题的安卓版本【必填】:请填写出现问题的 Android 版本 android 12

    请回答

    • 是部分机型还是所有机型都会出现【必答】:部分/全部(例如:某为,某 Android 版本会出现)所有

    • 框架最新的版本是否存在这个问题【必答】:是/否(如果用的是旧版本的话,建议升级看问题是否还存在)是

    • 是否已经查阅框架文档还未能解决的【必答】:是/否(文档会提供最常见的问题解答,可以看看是否有自己想要的)是

    • issue 是否有人曾提过类似的问题【必答】:是/否(看看曾经有人提过类似的问题,先参考一下别人是怎么解决的)否

    • 是否可以通过 Demo 来复现该问题【必答】:是/否(排查一下是不是自己的项目代码写得有问题导致的)是

    • 使用原生的 shape.xml 来实现是否也会出现该问题【必答】:是/否(排查一下是不是框架的代码存在问题导致的)否

    其他

    • 提供报错堆栈(如果有报错的话必填,注意不要拿被混淆过的代码堆栈上来)

    • 提供截图或视频(根据需要提供,此项不强制)

    a542485497e3867c265e2ca33e68ccb e686a64a05504fb48be9c5752327ae8

    • 提供解决方案(如果已经解决了的话,此项不强制)
    bug 
    opened by sdjwj1118 5
Owner
Android轮子哥
专业造轮子
Android轮子哥