android - 如何通过动态应用主题来更改 TextView 、按钮、编辑文本的角的形状?

标签 android android-widget styles themes

这是我的代码。我从未在我的申请中看到任何变化。我在 resources/drawable 中创建了它。我应该如何通过更改文本 colorfontsshapes 等为所有组件动态应用主题

 <?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/

相关文章:

机器人 : option menu doesn't work correctly

android - 当我单击 ListView 时,将按钮可见性设置为 GONE

javascript - JavaScript 中否定后的空格

java - 没有在 TextView 上获取样式

android - 如何在通知进入android时获取Bundle数据

android.support.design.chip.Chip

android - 编辑文本 : Disable Paste/Replace menu pop-up on Text Selection Handler click event

android - 每个小部件实例的不同设置

android - 如何在应用程序小部件中设置向下滑动和向上滑动手势?

php - PHP中的公共(public)静态函数和静态公共(public)函数有什么区别?