我有一个包含标签的活动。当我不使用应用程序背景作为具有以下代码的图像时,布局工作正常。
<style name="AppTheme" parent="AppBaseTheme">
<!-- <item name="android:background">@drawable/imagese4copy</item>
All customizations that are NOT specific to a particular API-level can go here. -->
</style>
布局看起来像:
当我包含背景图像时,它看起来像:
这是我的MainActivity.java
public class MainActivity extends TabActivity {
private TabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources resource = getResources();
tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setup();
Intent intentHelper = new Intent(this, Helper.class);
TabSpec tabSpecHelper = tabHost
.newTabSpec("Helper")
.setIndicator("",
resource.getDrawable(R.drawable.ic_launcher))
.setContent(intentHelper);
Intent intentRequest = new Intent(this, HelpRequest.class);
TabSpec tabSpecRequest = tabHost
.newTabSpec("HelpRequest")
.setIndicator("",
resource.getDrawable(R.drawable.ic_launcher))
.setContent(intentRequest);
Intent intentSetting = new Intent(this, SettingsActivity.class);
TabSpec tabSpecSetting = tabHost
.newTabSpec("Setting")
.setIndicator("",
resource.getDrawable(R.drawable.ic_launcher))
.setContent(intentSetting);
tabHost.addTab(tabSpecHelper);
tabHost.addTab(tabSpecRequest);
tabHost.addTab(tabSpecSetting);
tabHost.setCurrentTab(0);
}
和activity_main_activity.xml
<?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">
<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="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</TabHost>
和AndroidManifest.xml
:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.maptest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.maptest.HelpRequest"
android:label="@string/title_activity_help_request" >
</activity>
<activity
android:name="com.example.maptest.Helper"
android:label="@string/title_activity_helper" >
</activity>
<activity
android:name="com.example.maptest.SettingsActivity"
android:label="@string/title_activity_settings" >
</activity>
</application>
</manifest>
请告诉我当我包含背景图片时出了什么问题以及如何纠正它。
问候,
苏拉布