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

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

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

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

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

Android Studio

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

Q&A

解決済

4回答

3091閲覧

このxmlのコードは何が問題なのでしょうか?ScrollViewにエラーが出ます。よろしくお願いします

edoooooo

総合スコア476

XML

XMLは仕様の1つで、マークアップ言語群を構築するために使われています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

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

Android Studio

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

0グッド

0クリップ

投稿2016/11/30 12:24

編集2016/12/01 10:52

java

1<?xml version="1.0" encoding="utf-8"?> 2 3<FrameLayout 4 xmlns:android="http://schemas.android.com/apk/res/android" 5 xmlns:tools="http://schemas.android.com/tools" 6 7 android:layout_width="match_parent" 8 android:layout_height="match_parent" 9 10 tools:context="com.example.android.sample.calculator.MainActivity"> 11 12 <ScrollView 13 layout_width="match_parent" 14 layout_height="match_parent"> 15 16 <RelativeLayout 17 android:layout_width="wrap_content" 18 android:layout_height="wrap_content" 19 android:layout_gravity="top|center_horizontal" 20 android:layout_marginTop="35dp" 21 android:paddingLeft="@dimen/activity_horizontal_margin" 22 android:paddingRight="@dimen/activity_horizontal_margin" 23 android:paddingTop="@dimen/activity_vertical_margin" 24 android:paddingBottom="@dimen/activity_vertical_margin" 25 > 26 27 <EditText 28 android:layout_width="wrap_content" 29 android:layout_height="wrap_content" 30 android:inputType="number" 31 android:ems="10" 32 android:id="@+id/numberInput1" 33 android:layout_alignParentTop="true" 34 android:layout_alignParentStart="true" 35 android:layout_marginTop="52dp" 36 android:hint="@string/hint_input_number" /> 37 38 39 <!--このボタンにエフェクト--> 40 <Button 41 android:layout_width="wrap_content" 42 android:layout_height="wrap_content" 43 android:id="@+id/calcButton1" 44 android:layout_toEndOf="@+id/numberInput1" 45 android:text="@string/button_calc" 46 android:singleLine="true" 47 android:background="@drawable/button_background_ripple" 48 android:layout_alignBaseline="@+id/numberInput1" /> 49 50 <Spinner 51 android:layout_width="wrap_content" 52 android:layout_height="wrap_content" 53 android:id="@+id/operatorSelector" 54 android:layout_below="@+id/calcButton1" 55 android:layout_marginTop="35dp" 56 android:entries="@array/operators" 57 android:layout_alignEnd="@+id/numberInput1" /> 58 59 <EditText 60 android:layout_width="wrap_content" 61 android:layout_height="wrap_content" 62 android:inputType="number" 63 android:ems="10" 64 android:id="@+id/numberInput2" 65 android:layout_below="@+id/operatorSelector" 66 android:layout_alignParentStart="true" 67 android:hint="@string/hint_input_number" 68 android:textSize="@dimen/primary_text_size" 69 android:layout_marginTop="35dp" 70 android:layout_alignEnd="@+id/numberInput1" /> 71 72 <Button 73 android:layout_width="wrap_content" 74 android:layout_height="wrap_content" 75 android:text="@string/button_calc" 76 android:id="@+id/calcButton2" 77 android:layout_alignTop="@+id/numberInput2" 78 android:layout_toEndOf="@+id/numberInput2" /> 79 80 <TextView 81 android:layout_width="wrap_content" 82 android:layout_height="wrap_content" 83 android:text="@string/calc_result_text" 84 android:id="@+id/calcResult" 85 android:layout_below="@+id/calcButton2" 86 android:layout_alignEnd="@+id/numberInput2" 87 android:layout_marginTop="35dp" 88 android:textColor="#000000" 89 android:textSize="18sp" /> 90 91 <Button 92 android:layout_width="wrap_content" 93 android:layout_height="wrap_content" 94 android:text="@string/button_next" 95 android:id="@+id/nextButton" 96 android:layout_below="@+id/calcResult" 97 android:layout_alignParentEnd="true" 98 android:layout_marginTop="35dp" 99 android:background="@drawable/button_background" 100 android:layout_alignEnd="@+id/calcButton2" /> 101</RelativeLayout> 102 103 </ScrollView> 104</FrameLayout> 105 106

このように出ます。どうぞよろしくお願いします。
イメージ説明

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

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

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

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

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

guest

回答4

0

  1. RelativeLayout を Framelayoutの中に入れる目的が良く分からない、RelativeLayoutではいけないのかな?
  2. android:hint="数字を入力"というような直接テキスト(特に日本語)を入れるのは行儀が悪い、resourceを使うべきではないかと思います。
  3. android:singleLine="true"は非推奨、そもそも何がしたいのかわからない

投稿2016/12/01 05:33

aja

総合スコア3733

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

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

edoooooo

2016/12/01 10:07

ほんのコードを写していたのですが、実行できなくてこのような質問になりました。 直接テキストなどは、その後の参考書のページで修正しました。 アドバイスありがとうございます。
aja

2016/12/01 10:14

>ほんのコードを写していたのですが 前提として何かしたいのか明確にしてもらえれば方向性が見えます
edoooooo

2016/12/01 10:37

計算機アプリを作って学ぶ、リソースのレイアウトと動作の基本 という内容です。 Nexus7という、横幅のサイズの大きなスマホでも、左に偏らないようにするために、RelativeLayoutの外側に、もう一つレイアウトを作成します。 追加するレイアウトは、RelativeLayoutでもいいのですが、今回は、軽量なFrameLayoutを使うとのことです。
edoooooo

2016/12/01 10:54

無事エラーがなくなりました。次の質問からは、作りたい機能の説明も書くようにします。 ありがとうございました。
guest

0

xmlns:androidを2回宣言しており、後者のほうで上書きされてしまっているのではないでしょうか?
"http://schemas.android.com/apk/res-auto"という名前空間内にはlayout_heightなどは存在しない、ということでは?
なので、2回目のこの宣言を消すといいのではないでしょうか。

投稿2016/12/01 02:21

swordone

総合スコア20651

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

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

edoooooo

2016/12/01 10:53 編集

ありがとうございました。 xmlnsを消したところできました。
guest

0

ベストアンサー

下記のxmlns以外のxmlnsを消して再度試して見てください。
xmlns:android="http://schemas.android.com/apk/res/android"

投稿2016/11/30 13:38

yona

総合スコア18155

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

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

edoooooo

2016/12/01 10:01

Attribute is missing the Android namespace prefix と ScrollVIew の layout_width="match_parent" にこのようなエラーが出ました。 xmlns:tools="" は、消すとtools:context="" にエラーが出るので消しませんでした。 xmlns:android="http://schemas.android.com/apk/res-auto" これだけ消しました。 よろしくお願いします。
yona

2016/12/01 10:34

質問のコードにScrollViewなんて無いですよね?なにかの誤りですか?
edoooooo

2016/12/01 10:42

申し訳ありません。色々試してた時に、変えていました。 ScrollViewを削除したところ、エラーは無くなりました。 質問文をScrollViewの入ったコードに変えたのですが、 ScrollVIew の layout_width="match_parent" にこのようなエラーが出ました。 Attribute is missing the Android namespace prefix 教えていただけないでしょうか よろしくお願いします。
yona

2016/12/01 10:46

android:が無いからですね。 質問中にコードを変えたら質問を修正してください。
edoooooo

2016/12/01 10:52

ありがとうございました。できました。
guest

0

エラーメッセージどおりだと思いますが、
FrameLayout に layout_height と layout_widthが定義されていないのがエラーになっているのだと思います。

投稿2016/11/30 12:43

array

総合スコア57

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

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

edoooooo

2016/11/30 12:45

ありがとうございます。 android:layout_width="match_parent" android:layout_height="match_parent" このようにFrameLayoutをしているのですが、定義できていないのでしょうか? 教えていただけないでしょうか?
edoooooo

2016/12/01 10:44

xmlnsが重複していたところを削除し、エラーを無くすことができました。ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問