带滚动条的Android滑动选项卡
我正在使用材质滑动选项卡来显示滑动3不同的碎片布局。 这是“滑动”选项卡的xml布局:带滚动条的Android滑动选项卡,android,layout,android-viewpager,swipe,Android,Layout,Android Viewpager,Swipe,我正在使用材质滑动选项卡来显示滑动3不同的碎片布局。 这是“滑动”选项卡的xml布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:or
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
<com.android4devs.slidingtab.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="2dp"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
</LinearLayout>
现在,滑动的xml布局片段有一个固定在布局底部的按钮,因此当我滑动到该片段时,片段的布局被剪切,请参见图:
有没有办法将布局片段固定到ViewPager中,或者用滚动视图滚动它
谢谢在您的第二个
片段中,您可以使用
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
要将ScrollView
滚动到底部,您的按钮将完全可见。您可以在片段中使用ScrollView。或者在片段中使用RelativeLayout。ScrollView必须由R.id定义?在片段中,您可以执行ScrollView ScrollView=(ScrollView)yourRootView.findViewById(R.id.yourScrollViewId)代码>。可以,但滚动视图必须添加到ViewPager的布局中?不,在片段布局中。您可以将其设置为父/根视图。