这是我的代码。我从未在我的申请中看到任何变化。我在 resources/drawable
中创建了它。我应该如何通过更改文本 color
、fonts
、shapes
等为所有组件动态应用主题
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" android:padding="20dp">
<solid android:color="#FFA500"/>
<corners android:bottomRightRadius="50dp" android:bottomLeftRadius="50dp"
android:topLeftRadius="50dp" android:topRightRadius="50dp"/>
<stroke android:color="#FFA500" android:dashWidth="50dp" />
</shape>
最佳答案
在drawable中创建一个shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
android:shape="rectangle">
<gradient
android:startColor="#99CCFF"
android:endColor="#99CCFF"
android:angle="45"/>
<padding android:left="6dp"
android:top="6dp"
android:right="6dp"
android:bottom="6dp" />
<corners android:radius="30dp" />
</shape>
现在为您的 Button 代码添加 android:background,如下所示。
<Button
android:id="@+id/bt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape"/> // shape is name of xml file created
关于android - 如何通过动态应用主题来更改 TextView 、按钮、编辑文本的角的形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12208878/