自定义圆角控件和气泡尖角控件(气泡提示)

SharpView是一款适用于Android平台的自定义控件,提供带有微信风格聊天尖角的TextView、LinearLayout等组件。支持通过XML及代码配置圆角、尖角大小、背景颜色等多种属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SharpView gitgub地址

这是一个自定义控件,带有微信聊天尖角。目前有TextView,

Screenshots

在这里插入图片描述

Import


 Step 1. Add the JitPack repository to your build file
 Add it in your root build.gradle at the end of repositories:
 
	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}



Step 2. Add the dependency

	dependencies {
	        compile 'com.github.zengzhaoxing:SharpView:v2.4.4'
	}

Maven

Step 1.
<repositories>
   <repository>
	  <id>jitpack.io</id>
	  <url>https://jitpack.io</url>
   </repository>
</repositories>

Step 2. Add the dependency
<dependency>
    <groupId>com.github.zengzhaoxing</groupId>
    <artifactId>SharpView</artifactId>
    <version>v2.4.4</version>
</dependency>

Directions

  • custom properties
nameformatinstructions
radiusdimension圆角大小
backgroundColorcolor背景颜色(注意不要是用安卓原生的背景相关的属性(如:background,backgroundResource等))
arrowDirectionenum尖叫汽包相对位置(top,left,right,bottom)
relativePositionfraction尖叫汽包相对位置,百分比
sharpSizedimension尖叫汽包大小,为0表示不显示尖叫,默认是0
borderdimension边框大小,默认是0
borderColorcolor边框颜色
startBgColorcolor渐变初始颜色(渐变时必选)
middleBgColorcolor渐变中间颜色(渐变时可选)
endBgColorcolor渐变结束颜色(渐变时必选)

渐变颜色只有在sharpSize(没有尖角)为0时有效

Usage


       <com.zhaoxing.view.sharpview.SharpTextView
           android:layout_width="200dp"
           android:layout_height="70dp"
           android:textColor="@android:color/white"
           android:text="this is a SharpTextView"
           android:gravity="center"
           android:textSize="18sp"
           app:radius="5dp"
           app:arrowDirection="top"
           app:backgroundColor="#f0000000"
           app:relativePosition="20%"
           app:sharpSize="10dp"
           />
   
       <com.zhaoxing.view.sharpview.SharpLinearLayout
           android:id="@+id/sharp_ll"
           android:layout_width="300dp"
           android:layout_height="100dp"
           android:orientation="vertical"
           android:paddingBottom="5dp"
           android:paddingTop="5dp"
           android:paddingLeft="10dp"
           android:layout_marginTop="50dp"
           app:radius="5dp"
           app:arrowDirection="right"
           app:backgroundColor="#f0000000"
           app:relativePosition="100%"
           app:sharpSize="10dp">
   
   
       </com.example.xianzi.sharpview.SharpLinearLayout>


SharpLinearLayout sharpLinearLayout = (SharpLinearLayout) findViewById(R.id.sharp_ll);
//get the SharpViewRenderProxy of the sharpView to refresh sharp)
sharpLinearLayout.getRenderProxy().setArrowDirection(SharpView.ArrowDirection.BOTTOM);
sharpLinearLayout.getRenderProxy().setSharpSize(50);
sharpLinearLayout.getRenderProxy().setRelativePosition(0.8f);
sharpLinearLayout.getRenderProxy().setRadius(20);
sharpLinearLayout.getRenderProxy().setBackgroundColor(0xff000000);//注意不要使用安卓原生的设置背景的相关方法(如setBackground,setBackgroundResource等)

Usage

目前支持的气泡尖角或圆角控件和安卓原生控件继承关系如下

public class SharpEditText extends EditText
public class SharpTextView extends TextView 
public class SharpLinearLayout extends LinearLayout
public class SharpRelativeLayout extends RelativeLayout 
public class SharpImageView extends ImageView 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值