다른 b.xml 레이아웃에 포함 된 a.xml 레이아웃에있는보기에 액세스해야합니다. 예를 들어 , 이 내가 자바에서 할 경우는 있어야하기 때문에 후, XML 코드에서 그것을 할 필요가포함 된 XML 레이아웃에 대한 액세스보기
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include
android:id="@+id/a_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="@layout/a" />
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/xyz"
android:text="Show me below xyz" />
</RelativeLayout>
b.xml에,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/xyz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="XYZ" />
</RelativeLayout>
a.xml이며, setContentView()를 실행하고 TextView 'Label'의 LayoutParams를 설정하면 효과가 없습니다.
누구나 내가 물어 보려는 것을 이해합니다. 좋은 응답을 기다리고 있습니다.
감사합니다.
오른쪽의 이미지는 현재 코드에서 얻고 자하는 것입니다.
android:layout_below="@id/xyz"
android:layout_below="@id/a_layout"
에 그리고 당신은 내가에 배치 여기 (코드에서 사용할 수 있습니다 :
물어하려고 무엇 :이
a
+b
레이아웃 조합과 같은 동작을 관찰 할 수있다? –내가 짐작했다면, id :'findViewById (R.id.label)' –
에 액세스하십시오. 맞습니다. findViewById (R.id.label)를 사용하여 액세스 할 수 있습니다. 하지만이 안드로이드를 할 수 없어 : layout_below = "@ id/xyz" –