【发布时间】:2016-04-25 19:18:25
【问题描述】:
在您将其标记为重复之前,让我告诉您,我已经搜索了所有答案,但都是徒劳的。
我正在使用 Tabs 和 Actionbar。
我已按照许多解决方案中的建议设置了 android:layout_height="match_parent" 或 ScrollView。
我还按照以下建议从所有布局中删除了android:layout_gravity="center":
Android scrollview hiding top content in layout
我也设置了android:fillViewport="true",但没有运气。
我还缺少其他任何技巧吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<CalendarView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/calendarView" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Guest"/>
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</NumberPicker>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_time_slot"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_add_on"/>
<Button
android:id="@+id/btn_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_btn_confirm"/>
</LinearLayout>
</ScrollView>
这是活动的xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.squincy.wspace.ui.HomeActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="@color/app_color_black"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
app:tabIndicatorColor="@color/app_color_black"
app:tabGravity="center"
app:tabMode="scrollable"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<!--<android.support.design.widget.FloatingActionButton-->
<!--android:id="@+id/fab"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_gravity="end|bottom"-->
<!--android:layout_margin="@dimen/fab_margin"-->
<!--android:src="@android:drawable/ic_dialog_email" />-->
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
可以提供截图吗?
-
@petey 当然。检查更新
-
尝试在 LinearLayout 上添加一个 layout_marginBottom,它是 ScrollView 的直接子级,看看它是否调整
-
@ljpv14 没用。
-
您是否使用
ActionBar并将navigationMode设置为NAVIGATION_MODE_TABS?如果是这样,请尝试将其更改为使用Toolbar和TabLayout,因为ActionBar#setNavigationMode已被弃用。
标签: android android-scrollview