android设置style
参考博客:https://developer.android.google.cn/guide/topics/ui/look-and-feel/themes?hl=zh-cn
在资源中创建styles.xml
内容例如:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="macAddressEditTextStyle" parent="TextAppearance.AppCompat">
<item name="android:textColor">#000000</item>
<item name="android:textSize">25sp</item>
<item name="android:gravity">center</item>
</style>
</resources>
记得要加那个parent="TextAppearance.AppCompat"
然后在布局中使用例如:
注意虽然文件名为styles,但是用的适合却是style
<EditText
android:id="@+id/macAddressEditText"
style="@style/macAddressEditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_marginTop="100dp"
android:hint="@string/macAddress"
android:inputType="text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>