是否可以在 main.xml 中指定 Android 按钮的边框?
[注:
没有“包含笔划标记的单独 xml 文件”,但在我定义按钮的原始文件中
没有“动态编程”解决方案
和“图像”解决方案]
<Button
android:background="#FFFFFF"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Player 3"
android:layout_x="0px"
android:layout_y="0px"
android:id="@+id/p3"
android:layout_weight="1"
/>
在这里,我动态更改背景,但问题是,对于 2 个按钮,没有边框。
尝试使用形状
my_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:radius="0.1dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#E8E6E7" />
</shape>
和按钮
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/my_shape"
android:text="Button" />
截屏
我希望这能帮到您。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)