2012-12-07 68 views
0

我正在使用2 TabActivity控件的应用程序。当我设置任何选项卡的背景图像时,它会覆盖整个屏幕,甚至可以覆盖选项卡控件。但是选项卡控件仍保留在图像的背面。这真是奇怪的行为。任何人都请帮助我。背景图像溢出标签

这里是我的主选项卡控件的代码:\

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dp"> 
    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" /> 
    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp" /> 
</LinearLayout> 

这里是选项卡的代码谁是被添加背景:

TAB1:

public class FirstTab extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main); 

    /* First Tab Content */ 
    TextView textView =(TextView) findViewById(R.id.textview); 
    textView.setText("First Tab"); 
} 

}

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:background="@drawable/lux"> 

<TextView 
    android:id="@+id/textview" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

</LinearLayout> 

力士图片显示了整个屏幕上......我希望它的选项卡下显示。任何帮助表示赞赏。

+0

背景是9-patch png吗? –

+0

@ Singularity ...编号 –

+0

然后,我建议使用9贴片图像,因为它会缩放以适合容器。 –

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:background="@drawable/lux"> 

看到你layoutSet高度和宽度填充母,使其WRAP_CONTENT并保持勒克斯图像尺寸非常小,适合在标签上,或使高度和宽度DP说48dp/64dp/72dp/96dp