1.图片效果展示
2.正确使用
3.刷新方法
1.图片效果展示
image.png2.正确使用
- layout_feed_tag.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:backgroundTint="@color/color_gray"
android:textColor="@color/color_2f2"
android:textSize="@dimen/sp_12"
app:icon="@drawable/icon_tag"
app:iconGravity="textStart"
tools:text="程序员在测试"
app:cornerRadius="@dimen/dp_25"
app:iconPadding="@dimen/dp_4"
app:iconSize="@dimen/dp_12"
app:iconTint="@color/color_theme"/>
- 在styles.xml中要配置,这样才能显示正常大小和图标
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="materialButtonStyle">@style/materialButton</item>
</style>
<style name="materialButton" parent="Widget.MaterialComponents.Button">
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:paddingTop">4dp</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:insetLeft">0dp</item>
<item name="android:insetRight">0dp</item>
<item name="android:insetBottom">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">0dp</item>
</style>
网友评论