在这张照片中,我试图让图像占据整个黑色的顶部和底部区域。我在这里查看了这些链接,但到目前为止我没有任何运气:
http://joshclemm.com/blog/?p=136
编码:
主要活动:
// Add the Tabs/////////////////////////////////////////////
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
specs = th.newTabSpec("tag1");
specs.setContent(R.id.tab1);
specs.setIndicator("", getResources().getDrawable(R.drawable.b_news));
th.addTab(specs);
specs = th.newTabSpec("tag2");
specs.setContent(R.id.tab2);
specs.setIndicator("Library");
th.addTab(specs);
specs = th.newTabSpec("tag3");
specs.setContent(R.id.tab3);
specs.setIndicator("Community");
th.addTab(specs);
main_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ffffff" >
<LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<ListView
android:id="@+id/libraryListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:ignore="InefficientWeight" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<ListView
android:id="@+id/communityListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:ignore="InefficientWeight" >
</ListView>
</LinearLayout>
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-4dp"
android:layout_weight="0" >
</TabWidget>
</LinearLayout>
</TabHost>
</RelativeLayout>