windows_backgraound.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-14.5dp"
android:left="-15dp"
android:right="-14.9dp"
android:top="-15.1dp"
android:id="@+id/my_shape">
<shape android:shape="rectangle">
<stroke
android:width="15dp"
android:color="#000000" />
<corners android:radius="40dp" />
</shape>
</item>
</layer-list>
MyWindowManagerService.java
ImageView mView = new ImageView(this);
mView .setImageDrawable(ContextCompat.getDrawable(this, R.drawable.windows_backgraound));
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW,
PixelFormat.TRANSLUCENT);
wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(mView, params);
我的问题是我想以编程方式更改可绘制资源半径
答案 0 :(得分:0)
找到解决方案
float[] statusRadii = new float[]{12, 12, 12, 12, 12, 12, 12, 12}; // For Corners
GradientDrawable approvedStatusBg = new GradientDrawable();
approvedStatusBg.setShape(GradientDrawable.RECTANGLE);
approvedStatusBg.setCornerRadii(statusRadii);
approvedStatusBg.setColor(Color.parseColor("#66BB6A"));