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元のボタンをどう呼べばいいのか、ご教示の程よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/14 00:15