我正在使用android tabhost的應用程序。我面臨使用它的問題,因爲我的活動佈局在標籤下顯示不正確。活動的佈局只顯示在仿真器屏幕的上半部分,下半部分保持黑色,而當我在設計視圖中看到它的xml時,它將描述所需的設計。
XML如下添加myscreen.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/gray"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/button_twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/twitter_login_unpressed" />
<ImageView
android:id="@+id/button_separator"
android:layout_width="wrap_content"
android:layout_height="30px"
android:background="@color/gray" />
<ImageView
android:id="@+id/button_facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/facebook_login_unpressed" />
</LinearLayout>
及有關活動只包含的onCreate下面的代碼:
protected void onCreate(Bundle savedInstanceState) {
Log.e("Now", "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.myscreen);
}
我無法弄清楚HY選項卡下的整個佈局沒有正確顯示,和tabActivity只是有和意圖這種活動,沒有什麼複雜的在那裏...它包含以下代碼:
公共類InfoTabActivity擴展TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.infotablayout);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, myActivity.class);
spec = tabHost.newTabSpec("settings").setIndicator("", res.getDrawable(R.drawable.today_unpressed)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
可能是什麼問題?任何幫助表示讚賞。
infotablayout.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="wrap_content"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="45px" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
可以在此添加的快照? – Hiral
你肯定..我補充說.... –
和請發佈您的infotablayout.xml。 – Hiral