Android:如何在右上角的按钮角添加三角形

Android:如何在右上角的按钮角添加三角形,第1张

概述我想在布局的右上角做一个带三角形按钮: 我已经开始没有这个三角形的布局了: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="48dp" androi 我想在布局的右上角做一个带三角形的按钮:

我已经开始没有这个三角形的布局了:

<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"     androID:layout_wIDth="match_parent"     androID:layout_height="48dp"     androID:gravity="center_vertical"     androID:paddingleft="@dimen/keyline_1"     androID:paddingRight="@dimen/keyline_2"><TextVIEw    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:textcolor="@color/grey"    androID:text="DESCRIPTION"/><linearLayout    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:orIEntation="horizontal"    androID:layout_alignParentRight="true">    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:paddingRight="@dimen/keyline_4"        androID:textcolor="@color/grey"        androID:text="info"/>    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:textcolor="@color/grey"        androID:text="Title"/></linearLayout></relativeLayout>
解决方法 使用下面的代码创建三角形形状并使其成为textvIEw背景
<?xml version="1.0" enCoding="utf-8"?><@R_318_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID" >    <item>        <rotate            androID:fromdegrees="-45"            androID:todegrees="45"            androID:pivotX="0%"            androID:pivotY="1%" >            <shape androID:shape="rectangle" >                <stroke                    androID:wIDth="10dp"                    androID:color="#00000000" />                <solID androID:color="#00ACED" />            </shape>        </rotate>    </item> </@R_318_3419@>

并使用下面的代码来旋转textvIEw

<TextVIEw                androID:ID="@+ID/won_text"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_alignParentleft="true"                androID:paddingtop="20dp"                androID:rotation="-45"                androID:text="@string/won"                androID:textAppearance="?androID:attr/textAppearanceLarge"                androID:textcolor="@androID:color/white"                androID:textSize="34sp" />

更多细节参见How to make custom textview in android?

总结

以上是内存溢出为你收集整理的Android:如何在右上角的按钮角添加三角形全部内容,希望文章能够帮你解决Android:如何在右上角的按钮角添加三角形所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1130930.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存