是否可以在 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 个按钮,没有边框。
最佳答案
尝试使用形状
我的形状.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" />
截图
希望对您有所帮助。
关于android - 是否可以在android按钮中指定边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17564884/