80,350
社区成员
发帖
与我相关
我的任务
分享
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 100);
Button result = new Button(context);
result.setLayoutParams(layoutParams);
result.setTextColor(context.getResources().getColor(R.color.color_white));
result.setBackground(context.getResources().getDrawable(R.drawable.shape_blue));
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/colorPrimary" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="30dip" />
<!--边框的宽度及颜色-->
<stroke android:width="2px" android:color="#fff" />
</shape>