【发布时间】:2020-01-16 02:56:18
【问题描述】:
我正在尝试使用具有材料主题的 google 按钮创建登录,但图标显示为白色块。我正在使用 google here 提供的登录资产。
如果我使用带有材质主题的材质按钮
按钮 XML
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_material"
style="@style/Widget.MaterialComponents.Button.Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign In with Google"
app:icon="@mipmap/ic_launcher_round" />
styles.xml
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
...
</style>
但是,如果我使用带有普通按钮的 appcompat 主题,它就可以正常工作
按钮 XML
<Button
android:id="@+id/btn_appcompat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@mipmap/ic_launcher_round"
android:text="Sign In with Google"
/>
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
...
</style>
那么我怎样才能让按钮图标在材质主题中正确显示呢?
【问题讨论】: