【发布时间】:2020-12-25 18:34:11
【问题描述】:
我找到了this question,解决方法是这段代码:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<corners
android:bottomLeftRadius="8dp"
android:bottomRightRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
此代码在我的 PC 上不起作用(没有圆角)。和你 ?有变化吗?
编辑 1: 构建项目时出现错误:AAPT: error: XML or text declaration not at the start of entity。 (终于更正了:我犯的愚蠢错误)
编辑 2 : 现在的错误是: 找不到以下类: - 角落(修复构建路径,编辑 XML) - 形状(修复构建路径,编辑 XML) - 实心(修复构建路径,编辑 XML) 提示:尝试构建项目。
XML 布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<shape
android:shape="rectangle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<solid android:color="#ffffff" />
<corners
android:bottomLeftRadius="120dp"
android:bottomRightRadius="120dp"
android:topLeftRadius="120dp"
android:topRightRadius="120dp" />
</shape>
</androidx.constraintlayout.widget.ConstraintLayout>
解决方案:
【问题讨论】:
-
请分享xml布局
标签: android kotlin android-drawable shapes