gpt4 book ai didi

Android tabcontent 包含将内容隐藏在选项卡后面的 ScrollView

转载 作者:太空狗 更新时间:2023-10-29 16:23:34 24 4
gpt4 key购买 nike

我有一个包含 Tabhost 的布局。选项卡位于屏幕底部。第一个选项卡启动一个 ActivityGroup。该 ActivityGroup 中的第一个 Activity 包含一个 ScrollView 。当内容显示在 ScrollView 中并且您一直向下滚动时, ScrollView 的底部隐藏在选项卡后面。有什么解决办法吗?

当我启动 Activity 组时,我使用这段代码:

Window window = getLocalActivityManager().startActivity(pActivityClass.getName(), intent);
setContentView(window.getDecorView());

装饰 View 是整个屏幕吗?我只希望 View 成为 tabcontent。这是主要布局:

<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>

这是我想要在选项卡内容中显示的 View :

<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>

最佳答案

修复您的布局,使内容 View 适合选项卡小部件上方,而不是填充整个父容器,这告诉它以 RelativeLayout 的完整大小进行布局,然后放置 TabWidget 在上面。更像这样:

<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:layout_above="@android:id/tabs"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>

我还删除了一些不必要的项目,例如 android:orientation,它在 RelativeLayout 中什么都不做。

HTH

关于Android tabcontent 包含将内容隐藏在选项卡后面的 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8232134/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com