代码块1: 我在view.xml中有以下代码
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#00FF00"
android:typeface="monospace"
android:text="@string/hello" />
代码块2:现在我想把它转换成这样的样式。
<TextView
style="@style/CodeFont"
android:text="@string/hello" />
代码块 3:在我的styles.xml文件中,我希望有这个。
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
将所有这些属性都包裹在<item name="XXX"/>
标签中是一个非常手动且令人讨厌的过程。 Android Studio 是否有某种魔法可以自动将代码块1中的属性转换为代码块3中的项标记?
重构 > 提取 > 样式...
- dieter