【问题标题】:The content of my tabs doesn't fill the whole space我的标签内容没有填满整个空间
【发布时间】:2012-04-13 12:10:14
【问题描述】:

在我的活动中,我动态创建了 5 个标签。

我想弄清楚为什么我的加载动画没有填满整个空间。现在它只是标签内容顶部的一个小矩形(参见http://imageshack.us/photo/my-images/594/loadingwf.png/)。

这是我创建每个选项卡内容的代码:

for (int i = 0; i < NewsCategory.values().length; i++) {
    View tabView = createTabView(tabHost.getContext(), NewsCategory.getValueAt(i).getName());

    tabNewslist[i] = new Newslist(this, NewsCategory.getValueAt(i));
    getLayoutInflater().inflate(R.layout.loading_anim, tabHost.getTabContentView(), true);
    tabHost.addTab(tabHost.newTabSpec(NewsCategory.getValueAt(i).getName()).setIndicator(tabView).setContent(R.id.loadingAnim));
}

这里是动画的 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/loadingAnim"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF"
    android:gravity="center_horizontal"
    android:orientation="horizontal"
    android:padding="5dp" >

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="@string/loading" />

</LinearLayout>

【问题讨论】:

    标签: android tabs android-tabhost


    【解决方案1】:

    我认为这部分代码是正确的。 你的活动 xml 中有什么?

    【讨论】:

    • 嗨,首先感谢您的宝贵时间。我觉得自己像个白痴,因为你是对的,我的代码是正确的......问题出在活动 XML 布局中,我只是将 wrap_content 更改为 fill_parent 并且它起作用了!
    猜你喜欢
    • 2017-03-07
    • 1970-01-01
    • 2018-08-15
    • 2020-11-24
    • 1970-01-01
    • 2020-11-22
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多