我正在尝试设置文本视图的重力" v"但它不起作用。基本上在这段代码中,通过文本视图创建了一个可绘制的位图...
private Drawable[] getDrawableFromData(String[] data) {
Drawable[] ret = new Drawable[data.length];
for (int i = 0; i < data.length; i++) {
TextView v = new TextView(this);
v.setText(data[i]);
v.setTypeface(TypeFaces.get(getApplicationContext(),
Constants.TYPE_FACE_PATH));
v.setBackgroundColor(Color.RED);
v.setTextSize(60);
v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v.setTextColor(Utils.getHexColor(SplashScreenData.getInstance().object.themeOptions.circular Wheel.TextColor));
v.setDrawingCacheEnabled(true);
v.layout(0, 0, 150, v.getMeasuredHeight() + 15);
//v.setLayoutParams(Gravity.CENTER);
v.setGravity(Gravity.CENTER);
v.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false);
Drawable d = new BitmapDrawable(getResources(), b);
ret[i] = d;
}
return ret;
}