Android选项卡意图,通过选项卡进行布局剪裁

Android选项卡意图,通过选项卡进行布局剪裁,android,android-layout,Android,Android Layout,我正在使用TabLayout创建一个应用程序,在使用意图加载不同的类时,我的显示出现了问题 我尝试使用这里看到的Android开发指南中解释的方法创建它 然而,我遇到的问题是,我希望标签沿着应用程序的底部,而不是我所做的顶部。问题是屏幕上没有足够的空间来查看整个应用程序,所以当我单击一个新选项卡并加载其布局时,它会直接通过选项卡。我尝试添加ScrollView,但似乎不起作用 关于如何解决这个问题的任何建议,以便当我加载屏幕时,我可以在页面上下滚动,我的选项卡始终显示在底部,而不是让我的布局剪

我正在使用TabLayout创建一个应用程序,在使用意图加载不同的类时,我的显示出现了问题

我尝试使用这里看到的Android开发指南中解释的方法创建它

然而,我遇到的问题是,我希望标签沿着应用程序的底部,而不是我所做的顶部。问题是屏幕上没有足够的空间来查看整个应用程序,所以当我单击一个新选项卡并加载其布局时,它会直接通过选项卡。我尝试添加ScrollView,但似乎不起作用

关于如何解决这个问题的任何建议,以便当我加载屏幕时,我可以在页面上下滚动,我的选项卡始终显示在底部,而不是让我的布局剪辑通过我的选项卡

任何帮助都将不胜感激

main.xml的代码是

<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:background="#92c223">

<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:padding="5dp">

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

</LinearLayout>

<TabWidget android:id="@android:id/tabs"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_gravity="bottom" />
</TabHost>

试试这个

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

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_weight="1"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>

    </LinearLayout>

</TabHost>

不同之处在于FrameLayout,高度设置为包裹内容,而您的内容设置为填充父内容。他还在FrameLayout上应用布局权重=1,在TabWidget上应用布局权重=0


摘自。

非常感谢,在中添加了代码,然后在其中添加了ScrollLayout,现在效果非常好。干杯:D
<?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">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:layout_weight="1"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"/>

    </LinearLayout>

</TabHost>