Я работаю над приложением, в котором мне нужно использовать 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);
}
Я не могу понятьпочему весь макет под вкладкой не отображается должным образом, а 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>