【发布时间】:2016-04-20 14:17:09
【问题描述】:
基本上我想要做的是让屏幕的一半是选项卡布局和一半图像(或其他任何东西)。在我开始增加体重之前它工作得很好。
照原样,没有显示任何内容。什么会导致这个问题?
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="left"
android:weightSum="2"
android:background="#00025a">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TabWidget
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs">
</TabWidget>
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@android:id/tabcontent">
</FrameLayout>
<FrameLayout
android:id="@+id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/test_room_1"/>
</android.support.v4.app.FragmentTabHost>
如果没有权重组件,选项卡相关的内容会显示,但我假设它会将图像推出,因为它没有显示。
任何帮助将不胜感激。 :)
更新:
这里是按要求提供的屏幕截图:Weighted
以及调用活动:
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.widget.ImageView;
public class sandbox_mode extends FragmentActivity {
ImageView level_background;
private FragmentTabHost mTabHost;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sandbox_mode_play);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
mTabHost.addTab(mTabHost.newTabSpec("Enemy Tab").setIndicator("Enemies"),
enemy_tab.class, null);
}
}
【问题讨论】:
-
可以加截图吗?
-
你如何称呼这个片段。请添加该代码。
标签: java android android-fragments android-tabhost