私は、両方のプラットフォームで動作する JS でアプリを作成できる、クロスプラットフォームの Android/IOS フレームワークの Android 半分に取り組んでいます。これは、この効果を得るために 9 パッチなどを使用できないことを意味するためです。https://github.com/mschulkind/cordova-true-native-androidの完全なコード
問題の 2 つのスクリーンショットを次に示します。
-私は新人すぎて役に立たないため、画像は編集されています。私が初心者でなくなったら、それらを追加する必要があります.-
https://github.com/mschulkind/cordova-true-native-android/blob/master/src/org/apache/cordova/plugins/truenative/ViewPlugin.java#L146からドローアブルを生成するコードは次のとおりです。
// Borrowed from:
// http://www.betaful.com/2012/01/programmatic-shapes-in-android/
private class ViewBackground extends ShapeDrawable {
private final Paint mFillPaint, mStrokePaint;
private final int mBorderWidth;
public ViewBackground(
Shape s, int backgroundColor, int borderColor, int borderWidth) {
super(s);
mFillPaint = new Paint(this.getPaint());
mFillPaint.setColor(backgroundColor);
mStrokePaint = new Paint(mFillPaint);
mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setStrokeWidth(borderWidth);
mStrokePaint.setColor(borderColor);
mBorderWidth = borderWidth;
}
@Override
protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
shape.resize(canvas.getClipBounds().right, canvas.getClipBounds().bottom);
Matrix matrix = new Matrix();
matrix.setRectToRect(
new RectF(
0, 0,
canvas.getClipBounds().right, canvas.getClipBounds().bottom),
new RectF(
mBorderWidth/2, mBorderWidth/2,
canvas.getClipBounds().right - mBorderWidth/2,
canvas.getClipBounds().bottom - mBorderWidth/2),
Matrix.ScaleToFit.FILL);
canvas.concat(matrix);
shape.draw(canvas, mFillPaint);
if (mBorderWidth > 0) {
shape.draw(canvas, mStrokePaint);
}
}
}
これは、ドローアブルが EditText の背景として直接設定された場合と、EditText の周りの親ビューの背景として設定された場合の両方で発生しました。
ここで何が起こっているのか、またはどのような道を探るべきかを知っている人はいますか?