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

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

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

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

Android

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

Android Studio

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

Q&A

解決済

1回答

573閲覧

include元のViewの呼び方

nagomi72

総合スコア51

XML

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

Android

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

Android Studio

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

0グッド

0クリップ

投稿2018/12/13 02:40

includeしたxmlに定義されているボタンを基準にレイアウトを定義しようと考えたのですが、
include元のボタンが見つけられていない状況です。

以下にソースを記載します。

include元
include.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="60dp" android:gravity="left" android:background="#000066"> <Button android:id="@+id/header_open_button" android:layout_width="35dp" android:layout_height="30dp" android:layout_marginTop="15dp" android:layout_marginLeft="10dp" android:background="@drawable/icon_side_menu_open" /> </LinearLayout>

include先
activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <!-- include --> <LinearLayout android:id="@+id/header_layout" android:layout_width="match_parent" android:layout_height="60dp"> <include layout="@layout/include" android:id="@+id/header_views"/> </LinearLayout> <!--include.xmlに定義されているheader_open_buttonから相対的に場所を指定したいが, 現状ではheader_open_buttonが見つけられていない--> <LinearLayout android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignTop="@+id/header_open_button" android:layout_alignBottom="@+id/header_open_button" android:layout_toRightOf="@+id/header_open_button"> <TextView android:id="@+id/count_text" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_weight="1" android:gravity="center" android:textSize="18sp" android:textColor="#eceae6" android:textStyle="bold" android:text="テスト"/> </LinearLayout> </RelativeLayout> </LinearLayout>

include先でinclude元のボタンをどう呼べばいいのか、ご教示の程よろしくお願いいたします。

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

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

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

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

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

guest

回答1

0

ベストアンサー

include以前にボタンと親子関係にないので無理かと。

投稿2018/12/13 10:26

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

nagomi72

2018/12/14 00:15

includeした時点でactivity_mainにinclude.xmlが埋め込まれ、親子関係になると勝手に考えていました…。 ご教授頂きありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問