Android 開発で、CustomViewの定義
画面表示のXML内に、任意のView(CustomView)で領域を張り付けます。

XMLの定義、CustomViewで定義します。
1 | < com.xxxx.yyyy.CustomView |
2 | android:layout_width = "160dp" |
3 | android:layout_height = "160dp" |
4 | android:id = "@+id/N02_view" |
5 | android:layout_gravity = "center" /> |
ソース上の定義は、TextViewと同等です。
2 | CustomView customView = (CustomView) findViewById(R.id.N02_view); |
4 | customView.setDrawingCacheEnabled( true ); |
5 | Bitmap bmp = customView.getDrawingCache(); |
CustomView内の定義は、以下の定義”extends View“で作成する。
Viewのデータを扱うとき、bitmapに変換してViewを扱います。
1 | public class CustomView extends View { |
3 | public CustomView(Context context, AttributeSet attrs) { |