android - 有没有可能在android中设计如下图的方法?
解决方案
创建可绘制文件 XML
half_circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:bottomLeftRadius="1000dp"
android:topLeftRadius="1000dp"
android:bottomRightRadius="0dp"
android:topRightRadius="0dp" />
<gradient
android:startColor="#32aef4"
android:centerColor="#44a0af"
android:endColor="#79e2e2"
android:angle="45"/>
</shape>
在布局文件夹中创建项目布局
项目.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="5dp"
android:text="sample"
android:textSize="25sp"
android:textColor="@android:color/black"/>
<RelativeLayout
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@drawable/half_circle">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_heart"
android:layout_centerInParent="true"
android:layout_margin="5dp"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
你可以实现以上。
PS - 请在 StackOverflow 中发布问题之前进行研究。请仔细阅读指南
推荐阅读
- css - React - Antd 模态最大宽度 [Modal.info() 方法]
- c# - Visual Studio C# 控制台不显示顶行
- html - pdf没有在iFrame中呈现
- javascript - 有没有办法从 WebRTC 生成 .mp4 URL?
- javascript - 渲染时如何在 React 中为视频标签设置 srcObject?
- css - 如何设置图像的最大高度?
- c++ - 更改 Win32 应用程序的全局亮度级别
- sql - 在 SELECT 查询中按多列排序
- javascript - 如何在多字段表单中执行 Firebase 存储图像上传到 getDownloadURL 并设置为状态以供 Redux 使用
- docker - 如何将普罗米修斯与服务监视器一起使用?