我刚开始使用<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|enterAlways">
<AutoCompleteTextView
android:id="@+id/ac_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:focusable="true"
android:hint="@string/search"
android:imeOptions="actionSearch"
android:singleLine="true"
android:visibility="gone"/>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="@+id/layout_search_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@color/white"
android:orientation="horizontal"
android:paddingStart="@dimen/_6sdp"
android:paddingEnd="@dimen/_6sdp">
<CheckBox
android:id="@+id/cb_search_deals"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/_6sdp"
android:layout_weight="0.45"
android:button="@drawable/checkbox_button"
android:checked="true"
android:paddingStart="@dimen/_8sdp"
android:text="@string/Search_for_Deals"
android:textSize="13sp"/>
<View
android:layout_width="0.25dp"
android:layout_height="match_parent"
android:layout_weight="0.015"
android:background="@color/grey"/>
<CheckBox
android:id="@+id/cb_search_business"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginStart="@dimen/_12sdp"
android:layout_weight="0.50"
android:button="@drawable/checkbox_button"
android:paddingStart="@dimen/_8sdp"
android:text="@string/Search_for_Business"
android:textSize="13sp"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/rl_search_results"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="start|center_vertical"
android:background="@color/red"
android:gravity="start|center_vertical">
<TextView
android:id="@+id/tv_search_results"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_toStartOf="@+id/iv_filter_results"
android:paddingStart="15dp"
android:text="Showing 10 Results"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="normal"/>
<ImageView
android:id="@+id/iv_filter_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="@drawable/ic_filter"/>
</RelativeLayout>
<ListView
android:id="@+id/lv_search_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:divider="@color/white"
android:dividerHeight="0dp"
android:scrollbars="none"
android:visibility="visible"/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/_12sdp"
android:paddingEnd="@dimen/_12sdp"
android:scrollbars="none"
android:background="@color/red"
app:tabTextColor="@color/tab_text_color"
app:tabIndicatorColor="@color/white"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/white"
app:tabTextAppearance="@android:style/TextAppearance.DeviceDefault.Small" />
<ImageView
android:layout_width="match_parent"
android:layout_height="48dp"
android:src="@drawable/tabs_overlay" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
<android.support.v4.view.ViewPager
android:id="@+id/home_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="locale"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<include layout="@layout/layout_navigation"/>
<include layout="@layout/layout_filter"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
和AppBar。我有一个布局 activity_home.xml
ViewPager
带有id=home_viewpager
的 listview.setNestedScrollEnabed(true)
是处理tablayout片段。
它只在Lollipop上工作正常,因为在代码中我设置了<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY" />
<include
layout="@layout/layout_filter_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/banner" />
</android.support.design.widget.AppBarLayout>
<com.app.views.MultiSwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_8sdp"
android:layout_below="@+id/header"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:divider="@null"
android:dividerHeight="@dimen/_8sdp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:text="@string/error_no_data"
android:textSize="24sp"
android:visibility="gone"/>
</FrameLayout>
</com.app.views.MultiSwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
android:indeterminateDrawable="@drawable/custom_progress"
style="?android:attr/progressBarStyle"/>
</RelativeLayout>
但是它不工作4.2.2也是viewpager的第一个片段(带有标题的listview)从底部被切断了ie未显示完整的屏幕内容。
在我的第二个viewpager片段中,布局名称为 fragment_top_deals
activity_home
问题是CoordinatorLayout
协调器布局+应用栏效果不起作用,而@Column(columnDefinition = "SMALLINT")
@Type(type = "org.hibernate.type.ShortType")
private short variableName;
和当前布局的Appbar工作正常。此实现也不适用于4.2.2。
答案 0 :(得分:1)
正如您所注意到的,ListView
仅支持从Lollipop开始的嵌套滚动(AppBarLayout
滚动支持的要求)。在此之前,您必须使用实现NestedScrollingChild的视图,例如RecyclerView或NestedScrollView。