{"id":341,"date":"2019-01-19T17:10:51","date_gmt":"2019-01-19T08:10:51","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=341"},"modified":"2019-01-19T17:10:51","modified_gmt":"2019-01-19T08:10:51","slug":"%e6%96%b9%e4%bd%8d%e8%a7%92%e3%82%92%e5%9f%ba%e3%81%ab%e7%94%bb%e5%83%8f%e3%82%92%e8%a1%a8%e7%a4%ba%e3%81%95%e3%81%9b%e3%81%9f%e3%81%84","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2019\/01\/19\/341\/","title":{"rendered":"\u65b9\u4f4d\u89d2\u3092\u57fa\u306b\u753b\u50cf\u3092\u8868\u793a\u3055\u305b\u305f\u3044"},"content":{"rendered":"<h2>SurfaceView\u3068\u304b<\/h2>\n<p>\u753b\u50cf\u3068\u304b\u3092\u9023\u7d9a\u3057\u3066\u63cf\u753b\u3059\u308b\u306e\u306b\u306f\u3001SurfaceView\u3068\u3044\u3046\u3082\u306e\u3092\u4f7f\u3046\u3068\u3044\u3044\u3089\u3057\u3044\u3002\u4ed6\u306b\u3082TextureView\u3068\u304bCustomView\u3068\u304b\u3042\u308b\u3089\u3057\u3044\u3093\u3060\u3051\u3069\u3088\u304f\u5206\u304b\u3089\u3093\u3002\u306a\u3093\u304bAndroid\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3054\u3068\u306b\u63a8\u5968\u3055\u308c\u305f\u5909\u9077\u304c\u3042\u308b\u3089\u3057\u3044\u3002\u307f\u3093\u306a\u4f7f\u3063\u3066\u305d\u3046\u3067\u3001\u30cd\u30c3\u30c8\u4e0a\u3067\u3082\u89e3\u8aac\u8a18\u4e8b\u304c\u3042\u308b\u7a0b\u5ea6\u898b\u3064\u304b\u308bSurfaceView\u3092\u4f7f\u3063\u3066\u307f\u305f\u3044\u3002<\/p>\n<h3>\u7121\u7406\u3067\u3057\u305f<\/h3>\n<p>\u9014\u4e2d\u307e\u3067\u9811\u5f35\u3063\u305f\u3093\u3060\u3051\u3069\u3001\u3084\u308a\u65b9\u304c\u3088\u304f\u308f\u304b\u3089\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3002SurfaceView.java\u3092\u65b0\u3057\u304f\u4f5c\u3063\u3066\u305d\u3053\u306b\u51e6\u7406\u3092\u66f8\u3044\u3066\u3001MainActivity.java\u3067setContentView\u3059\u308b\u611f\u3058\u306b\u3057\u305f\u3093\u3060\u3051\u3069\u3002\u30bb\u30f3\u30b5\u30fc\u306e\u5024\u306e\u53d6\u5f97\u3092Main\u306b\u66f8\u3044\u3066\u3066\u3001\u305d\u306e\u5024\u3092Surface\u306e\u65b9\u306b\u6e21\u3059\u3084\u308a\u65b9\u304c\u308f\u304b\u3089\u306a\u3044\u3002MainActivity\u306e\u4e2d\u3067SurfaceView\u3092\u6271\u3046\u3084\u308a\u65b9\u3082\u5206\u304b\u3089\u306a\u3044\u3002\u306e\u3067\u5225\u306e\u3084\u308a\u65b9\u3092\u63a2\u3059\u3002<\/p>\n<h4>\u53c2\u8003<\/h4>\n<p><a href=\"http:\/\/quesera2.hatenablog.jp\/entry\/2016\/08\/30\/233743\">http:\/\/quesera2.hatenablog.jp\/entry\/2016\/08\/30\/233743<\/a><\/p>\n<p><a href=\"https:\/\/blog.keiji.io\/2015\/12\/mincomi-adventcalendar-20.html\">https:\/\/blog.keiji.io\/2015\/12\/mincomi-adventcalendar-20.html<\/a><\/p>\n<p><a href=\"https:\/\/techbooster.org\/android\/application\/1195\/\">https:\/\/techbooster.org\/android\/application\/1195\/<\/a><\/p>\n<p><a href=\"https:\/\/techbooster.org\/android\/application\/1274\/\">https:\/\/techbooster.org\/android\/application\/1274\/<\/a><\/p>\n<h3>ImageView\u3092\u4f7f\u3046<\/h3>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-344\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle-300x300.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle-150x150.png 150w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle-100x100.png 100w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2019\/01\/needle.png 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u9069\u5f53\u306b\u4f5c\u3063\u305f\u753b\u50cf\u3092\u7528\u610f\u3002<\/p>\n<pre>&lt;ImageView\r\n    android:id=\"@+id\/imageView\"\r\n    android:layout_width=\"0dp\"\r\n    android:layout_height=\"0dp\"\r\n    android:layout_marginStart=\"8dp\"\r\n    android:layout_marginEnd=\"8dp\"\r\n    android:layout_marginBottom=\"8dp\"\r\n    app:layout_constraintBottom_toBottomOf=\"parent\"\r\n    app:layout_constraintEnd_toEndOf=\"parent\"\r\n    app:layout_constraintStart_toStartOf=\"parent\"\r\n    app:layout_constraintTop_toBottomOf=\"@+id\/textView\"\r\n    app:srcCompat=\"@drawable\/needle\" \/&gt;<\/pre>\n<p>ImageView\u3092\u8a2d\u7f6e\u3002<\/p>\n<pre>imageView = findViewById(R.id.imageView);\r\nbitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.needle);\r\nimagewidth = bitmap1.getWidth();\r\nimageheight = bitmap1.getHeight();<\/pre>\n<p>onCreate\u3067imageView\u306e\u53d6\u5f97\u3068drawable\u304b\u3089\u753b\u50cf\u3092\u53d6\u5f97\u3002<\/p>\n<pre>azimuth = (float) Math.toDegrees(attitude[0]);\r\nmatrix.setRotate(-azimuth, imagewidth \/ 2, imageheight \/ 2);\r\nBitmap bitmap2 = Bitmap.createBitmap(bitmap1, 0, 0, imagewidth, imageheight, matrix, true);\r\n\r\nimageView.setImageBitmap(bitmap2);<\/pre>\n<p>onSensorChanged\u3067\u65b9\u4f4d\u89d2\u304b\u3089Matrix\u3092\u4f7f\u3063\u3066setRotate\u3067\u65b0\u305f\u306bBitmap\u4f5c\u308b\u3002\u3067ImageView\u306b\u30bb\u30c3\u30c8\u3002\u3053\u308c\u8a08\u7b97\u5408\u3063\u3066\u308b\u304b\u306a\u3002<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/Bu_1fFEbvqo\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u56de\u3063\u305f!!\u306a\u3093\u304b\u30ab\u30af\u30ab\u30afw\u3042\u3068\u898b\u3066\u5206\u304b\u308b\u901a\u308a\u3001\u56de\u8ee2\u3059\u308b\u3054\u3068\u306b\u753b\u50cf\u304c\u62e1\u5927\u7e2e\u5c0f\u3057\u3066\u3057\u307e\u3046\u3002\u3059\u3063\u3054\u3044\u65b9\u89d2\u304c\u305a\u308c\u308b\u3002\u3044\u3063\u3071\u3044\u52d5\u304b\u3057\u305f\u308a\u3059\u308b\u3068\u3001\u30a2\u30d7\u30ea\u304c\u56fa\u307e\u308b\u3002\u3046\u30fc\u3093\u3001\u306a\u3093\u304b\u601d\u3063\u305f\u3088\u3046\u306a\u611f\u3058\u306b\u306a\u3063\u3066\u304f\u308c\u306a\u3044\u306a\u3041\u3002\u3081\u3093\u3069\u304f\u3055\u304f\u306a\u3063\u3066\u304d\u305f\u306a\u3041\u3002<\/p>\n<h4>\u53c2\u8003<\/h4>\n<p><a href=\"https:\/\/akira-watson.com\/android\/matrix.html\">https:\/\/akira-watson.com\/android\/matrix.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SurfaceView\u3068\u304b \u753b\u50cf\u3068\u304b\u3092\u9023\u7d9a\u3057\u3066\u63cf\u753b\u3059\u308b\u306e\u306b\u306f\u3001SurfaceView\u3068\u3044\u3046\u3082\u306e\u3092\u4f7f\u3046\u3068\u3044\u3044\u3089\u3057\u3044\u3002\u4ed6\u306b\u3082TextureView\u3068\u304bCustomView\u3068\u304b\u3042\u308b\u3089\u3057\u3044\u3093\u3060\u3051\u3069\u3088\u304f\u5206\u304b\u3089\u3093\u3002\u306a\u3093\u304bAndroi &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2019\/01\/19\/341\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[3,6,4,29],"class_list":["post-341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-8","tag-android","tag-androidstudio","tag-4","tag-29"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=341"}],"version-history":[{"count":2,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/341\/revisions"}],"predecessor-version":[{"id":345,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/341\/revisions\/345"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media\/344"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}