당신의 질문은 아마 내가 이해하고있는 것보다 더 복잡하다고 생각하지만, 당신이 겪은 일과 같은 것입니까?
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/some_xml_file"/>
</FrameLayout>
</LinearLayout>
</TabHost>
이 그런 다음 당신은 당신의 some_xml_file이 같은 정의 : @ 드로어 블과 함께 자신의 배경과 전망 (외부 RelativeLayout의 유지, 당신은 상단에 탭이있는 중첩 된 레이아웃을 제공
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/start_menu_background"
android:orientation="vertical"
android:id="@+id/just_a_test">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@drawable/techno"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true">
<TableLayout android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true">
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello world."/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I'm another cell"/>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Just more stuff"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="And one last one"/>
</TableRow>
</TableLayout>
</RelativeLayout>
</RelativeLayout>
을/start_menu_background), 그 하나는 자신의 배경 (차례대로 @ drawable/techo가있는 내부 RelativeLayout)을 가지며, 차례로 테이블에 몇 개의 행이 있습니다.
내가 그다지 행복하지 않다는 것은 내가 상대방 레이아웃의 높이를 하드 코딩해야한다는 것입니다. 항상 부모를 채우기를 원했던 것처럼 보였습니다 (배경 이미지의 크기에 관계없이). 그것). 그러나 당신은 그걸 가지고 놀 수 있고 당신이 얻는 것을 볼 수 있습니다.
물론이 기능을 사용하려면 TabHosts가 작동하도록 모든 코드를 작성해야합니다. 이전에이 두 가지 예 (official guide 및 another one)를 확인하십시오.
와우! 그것은 확실히 더 복잡하고 그것이 될 것이라고 생각합니다. 인터페이스에 대해 생각해 보면 탭이 없지만 두 가지 별도의 활동이 있다는 것이 더 합리적입니다. 활동 A는 위에서 설명한 활동이고 활동 B는 매우 간단합니다. 탭을 사용하지 않으면 some_xml_file 레이아웃으로 충분합니까? – mob1lejunkie
이어야합니다. 이 레이아웃은 몇 개의 중첩 된 ViewGroup이므로 실제로 그렇게 복잡하지는 않습니다. 그것들을 작동 시키려면 약간의 코드가 필요하기 때문에 탭과 함께 쓰면 약간 무서운 것처럼 보입니다. @ 레이아웃을 자신의 그림 파일로 변경해야하지만 위의 레이아웃을 Eclipse에서 미리 볼 수 있도록 복사/붙여 넣기 할 수 있어야합니다. –
그건 그렇고, 이것이 당신에게 효과가 있다면,이 대답을 '수락'으로 표시 할 수 있습니까? 이 대답의 왼쪽 상단에있는 녹색 눈금입니다. 또는 이것이 작동하지 않으면 저희에게 알려주십시오. –