質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

724閲覧

FrameLayout内のImageView 位置指定

S.I

総合スコア48

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2017/10/17 03:45

編集2017/10/17 08:23

画面横向き設定です。画面左側の枠内にネコの画像(neko5)を配置したいのですが、Design画面でDrag&Dropしてみたところ位置の変更ができません…座標で位置指定することは可能なのでしょうか…
ちなみに、ボタンをおしたらImageViewの画像が動くアプリをつくりたいと考えています。

activity_main.xml

java

1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent" 7 tools:context="com.example.nakahara.game.MainActivity"> 8 9 <LinearLayout 10 android:layout_width="0dp" 11 android:layout_height="match_parent" 12 android:layout_weight="1"> 13 14 <FrameLayout 15 android:layout_width="match_parent" 16 android:layout_height="match_parent"> 17 18 19 <com.example.nakahara.game.MyView 20 android:id="@+id/view" 21 android:layout_width="match_parent" 22 android:layout_height="match_parent" 23 android:layout_alignParentTop="true" 24 tools:layout_editor_absoluteX="26dp" 25 tools:layout_editor_absoluteY="17dp" /> 26 27 <ImageView 28 android:id="@+id/imageView" 29 android:layout_width="wrap_content" 30 android:layout_height="wrap_content" 31 app:srcCompat="@drawable/neko5" /> 32 33 34 </FrameLayout> 35 36 </LinearLayout> 37 38 <LinearLayout 39 android:layout_width="0dp" 40 android:layout_height="match_parent" 41 android:layout_weight="1" 42 android:orientation="vertical"> 43 44 <LinearLayout 45 android:layout_width="match_parent" 46 android:layout_height="0dp" 47 android:layout_weight="1"> 48 49 </LinearLayout> 50 51 <LinearLayout 52 android:layout_width="match_parent" 53 android:layout_height="0dp" 54 android:layout_weight="1" 55 android:orientation="vertical"> 56 57 <LinearLayout 58 android:layout_width="match_parent" 59 android:layout_height="match_parent" 60 android:layout_weight="1" 61 android:orientation="horizontal"> 62 63 <Button 64 android:id="@+id/button1" 65 android:layout_width="wrap_content" 66 android:layout_height="wrap_content" 67 android:layout_gravity="center" 68 android:layout_weight="1" 69 android:text="うえ" 70 android:background="#98fb98"/> 71 72 <Button 73 android:id="@+id/button2" 74 android:layout_width="wrap_content" 75 android:layout_height="wrap_content" 76 android:layout_gravity="center" 77 android:layout_weight="1" 78 android:text="した" 79 android:background="#fffacd"/> 80 81 <Button 82 android:id="@+id/button3" 83 android:layout_width="wrap_content" 84 android:layout_height="wrap_content" 85 android:layout_gravity="center" 86 android:layout_weight="1" 87 android:text="ひだり" 88 android:background="#ffc0cb"/> 89 90 <Button 91 android:id="@+id/button4" 92 android:layout_width="wrap_content" 93 android:layout_height="wrap_content" 94 android:layout_gravity="center" 95 android:layout_weight="1" 96 android:text="みぎ" 97 android:background="#afeeee"/> 98 99 </LinearLayout> 100 101 <LinearLayout 102 android:layout_width="match_parent" 103 android:layout_height="match_parent" 104 android:layout_weight="1" 105 android:orientation="horizontal"> 106 107 <TextView 108 android:id="@+id/textView1" 109 android:layout_width="wrap_content" 110 android:layout_height="wrap_content" 111 android:layout_gravity="center" 112 android:layout_weight="1" 113 android:text="プログラムのながれ" /> 114 </LinearLayout> 115 116 <LinearLayout 117 android:layout_width="match_parent" 118 android:layout_height="match_parent" 119 android:layout_weight="1" 120 android:orientation="horizontal"> 121 122 <Button 123 android:id="@+id/button6" 124 android:layout_width="wrap_content" 125 android:layout_height="wrap_content" 126 android:layout_weight="1" 127 android:text="スタート" /> 128 129 <Button 130 android:id="@+id/button5" 131 android:layout_width="wrap_content" 132 android:layout_height="wrap_content" 133 android:layout_weight="1" 134 android:text="やりなおし" /> 135 </LinearLayout> 136 137 <LinearLayout 138 android:layout_width="match_parent" 139 android:layout_height="match_parent" 140 android:layout_weight="1" 141 android:orientation="horizontal"> 142 143 <TextView 144 android:id="@+id/textView" 145 android:layout_width="wrap_content" 146 android:layout_height="wrap_content" 147 android:layout_gravity="center" 148 android:layout_weight="1" 149 android:text="のこりじかん" /> 150 151 </LinearLayout> 152 </LinearLayout> 153 </LinearLayout> 154</LinearLayout> 155

MyView.java

java

1package com.example.nakahara.game; 2 3 4import android.content.Context; 5import android.graphics.Bitmap; 6import android.graphics.BitmapFactory; 7import android.graphics.Canvas; 8import android.graphics.Color; 9import android.graphics.Paint; 10import android.util.AttributeSet; 11import android.view.View; 12 13public class MyView extends View { 14 public MyView(Context context) { 15 super(context); 16 } 17 18 public MyView(Context context, AttributeSet attrs) { 19 super(context, attrs); 20 } 21 22 Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.house); 23 24 25 26 27 @Override 28 protected void onDraw(Canvas canvas) { 29 Paint paint = new Paint(); 30 paint.setColor(Color.argb(255, 0, 0, 0)); 31 32 paint.setStyle(Paint.Style.STROKE); 33 canvas.drawRect(50, 50, 1000, 1300, paint); 34 canvas.drawLine(367,50,367,1300,paint); 35 canvas.drawLine(683,50,683,1300,paint); 36 canvas.drawLine(50, (float) 362.5,1000, (float) 362.5,paint); 37 canvas.drawLine(50,675,1000,675,paint); 38 canvas.drawLine(50, (float) 987.5,1000, (float) 987.5,paint); 39 40 canvas.drawBitmap(bmp1, 700, 100, paint); 41 } 42}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

Framelayoutを利用するのはやめました

投稿2017/10/17 10:25

S.I

総合スコア48

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問