Android tabcontent 包含滚动视图,它将内容隐藏在选项卡后面
我有一个包含 Tabhost 的布局。选项卡位于屏幕底部。第一个选项卡启动一个 ActivityGroup。该 ActivityGroup 中的第一个 Activity 包含滚动视图。当内容显示在滚动视图中并且一直向下滚动时,滚动视图的底部隐藏在选项卡后面。有什么想法如何解决这个问题吗?
当我启动活动组时,我使用以下代码:
Window window = getLocalActivityManager().startActivity(pActivityClass.getName(), intent);
setContentView(window.getDecorView());
装饰视图是否覆盖整个屏幕?我只希望视图成为选项卡内容。 这是主要布局:
<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">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentTop="true"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>
这是我想要在选项卡内容中看到的视图:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout android:id="@+id/myLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"/>
... a bunch of other components ...
</RelativeLayout>
</ScrollView>
I have a layout which contains a Tabhost. The tabs are at the bottom of the screen. The first tab starts an ActivityGroup. The first activity in that ActivityGroup contains a scrollview. When the contents are displayed in the scrollview and you scroll all the way down, the bottom of the scrollview is hidden behind the tabs. Any ideas how to fix this?
When I start the activitygroup, I use this code:
Window window = getLocalActivityManager().startActivity(pActivityClass.getName(), intent);
setContentView(window.getDecorView());
Is the decor view the entire screen? I just want the view to be the tabcontent.
Here is the main layout:
<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">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentTop="true"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>
Here is the view I want in the tabcontent:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myScrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout android:id="@+id/myLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"/>
... a bunch of other components ...
</RelativeLayout>
</ScrollView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
修复您的布局,使内容视图适合选项卡小部件上方,而不是填充整个父容器,这会告诉它按照
RelativeLayout
的完整大小进行布局,然后放置TabWidget< /代码> 在顶部。更像这样:
我还删除了一些不必要的项目,例如
android:orientation
,它在RelativeLayout
内部不执行任何操作。华泰
Fix your layout so the content view fits above the tab widget, instead of filling the entire parent container, which tells it to lay out as the full size of the
RelativeLayout
and then lay theTabWidget
on top. Something more like this:I also removed some of the unnecessary items like
android:orientation
which does nothing inside of aRelativeLayout
.HTH
最佳结果。
android:minWidth= 增加...的值
Optimal result.
android:minWidth= Increase the value of...
在这里,关键是,
Here, the key line is,
我知道可能有一种“正确”的方法来做到这一点,但我只是添加
到加载到选项卡中的 xml 文件的底部。
另外,user1060374 是正确的,FrameLayout 需要位于 Tabwidget 上方,否则如果内容需要滚动,滚动视图将隐藏(位于顶部)选项卡栏。
但仅仅这样做并不能回答你的问题,所以我添加了填充。
I know there might be a "correct" way to do this, but I just added
to the bottom of the xml file I was loading into the tab.
Also user1060374 is right the FrameLayout needs to be above the Tabwidget or the scrollview will hide(be on top of) the tabbar if the contents needs scrolled.
But just doing this won't answer your question, so I added the padding.