【问题标题】:Tab can not navigate and Tabs hide behind the main screen选项卡无法导航并且选项卡隐藏在主屏幕后面
【发布时间】:2013-06-03 15:46:38
【问题描述】:

在我的 android 应用主屏幕中有几个面板。在第一个面板中包含两个选项卡,它们将预定义的数据库信息显示为列表视图。问题是当主屏幕显示它覆盖两个选项卡的数据库信息时,基本上选项卡功能不再可用。有没有办法在 textview 之前给出行空间或明确区分?请查看图像文件。感谢您的任何建议或建议。

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"
    android:paddingTop="0px" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </FrameLayout>

</TabHost>

Java 代码

super.onCreate(savedInstanceState);
setContentView(R.layout.event_panel);

TabHost tabHost = getTabHost();

TabSpec spec1 = tabHost.newTabSpec("Tab 1");
spec1.setIndicator("Text-1");
Intent in1 = new Intent(this, Tab1.class);
spec1.setContent(in1);



TabSpec spec2 = tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Text-2");
Intent in2 = new Intent(this, Tab2.class);
spec2.setContent(in2);


tabHost.addTab(spec1);
tabHost.addTab(spec2);

tabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams(160, 35));
tabHost.getTabWidget().getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(160, 35));

【问题讨论】:

  • 请添加一些代码和/或xml
  • @QVDev 我刚刚添加了代码。谢谢。

标签: android tabs textview overlay


【解决方案1】:

您似乎以编程方式设置布局尝试更改此行的高度:

tabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams(290, 35));

35 似乎很小,我猜应该选择一个更大的数字来解决它

【讨论】:

  • 我正在更改此值以查看差异。我的 Tab 按钮现在位于后端,列表视图位于屏幕顶部 :(
  • 能否说的更具体一些,或者添加一张图片来展示结果?
  • 请看第一个屏幕,列表视图隐藏了屏幕顶部的两个标签,所以基本上我什至不能按任何标签按钮。请注意。我从数据库中检索的所有列表信息。在我的模拟器中,我可以用键导航,所以标签页肯定存在那里。
  • 所以更改值不起作用,最终得到相同的结果?
  • 更改值调整选项卡图标的大小。选项卡按钮不可点击,因为列表视图信息隐藏了选项卡视图。
猜你喜欢
  • 1970-01-01
  • 2010-12-22
  • 2021-02-10
  • 2022-01-20
  • 2022-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多