0
0

More than 3 years have passed since last update.

Android カスタムView

Posted at

Android カスタムViewを作成する際は、下記コンストラクタを記述すること
AttributeSet attrsが必要

MyView.java

public class MyView extends View {
    public MyView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {

    }
}
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.test.android.viewtest.MyView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
</LinearLayout>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0