【发布时间】:2019-10-09 19:55:05
【问题描述】:
见:
代码:
<RelativeLayout
android:id="@+id/circle_card_payment"
android:layout_width="40dp"
android:layout_height="40dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/colorBlack"
android:insetLeft="0dp"
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:text="W"
android:textColor="#FFFFFF"
android:textSize="16sp"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay_ButtonCircle50"
app:strokeWidth="0dp" />
</RelativeLayout>
style.xml
<style name="ShapeAppearanceOverlay_ButtonCircle50">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">20dp</item>
</style>
为了确认材料按钮包含完整空间,我将材料按钮颜色设置为黑色。并且里面的文字颜色是白色的。
有人可以根据我的情况给我确切的解决方案吗?请注意,您不应该将相对布局尺寸从 40 增加到 50 dp,我知道这可以解决问题,但 logo 尺寸会更大,这是不合适的。
请注意,我必须将此按钮包装在任何根布局中。这是强制性的。就像现在我的材质按钮在相对布局中。
【问题讨论】: