1

这是我的代码。我从未在我的应用程序中看到任何变化。我已经在resources/drawable. 我应该如何通过更改 text 等为所有组件动态应用样式中colorfonts主题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>
4

2 回答 2

1

在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
于 2012-08-31T04:58:25.700 回答
0

您上面的代码绝对可以正常工作。可能问题出在您声明背景的方式上:您是在 XML 文件中执行,还是通过 Java 代码动态执行?

于 2012-08-31T05:05:20.430 回答