Jav*_*Man 5 android android-fragments android-coordinatorlayout android-nestedscrollview
我有问题NestedScrollView,因为它削减了视图的底部.
我有FragmentA架构:
<RelativeLayout>
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<ImageView/>
<android.support.v7.widget.Toolbar/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView>
<LinearLayout>
<FrameLayout>
<!-- fragment added dynamically-->
</FrameLayout>
<FrameLayout>
<!-- fragment added dynamically-->
</FrameLayout>
<FrameLayout>
<!-- fragment added dynamically-->
</FrameLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我正在为每个添加dinamically片段FrameLayout.
当我第一次运行应用程序时,我做了SS的样子:我第一次在屏幕上
为每个布局添加填充以查看发生了什么.
green是CoordinatorLayout,
red是NestedScrollView,
orange在LinearLayout里面NestedScrollView.
现在我更换FragmentA用FragmentB,并再次复出FragmentA,我有这样的事情:错误dispaly
有人知道我做错了什么?
这是我的整个布局FragmentA:
<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:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorP"
android:padding="5dp"
android:layout_above="@+id/przyciski">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="160dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="25dp"
app:expandedTitleMarginEnd="0dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:contentDescription="descp" />
<android.support.v7.widget.Toolbar
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollableview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorRedCalendar"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:padding="5dp">
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:orientation="vertical"
android:padding="5dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frameForInfo"
android:minHeight="100dp"
android:focusableInTouchMode="true">
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frameForCalendar"
android:minHeight="100dp"
android:focusableInTouchMode="true">
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/frameForGraph"
android:minHeight="100dp"
android:focusableInTouchMode="true">
</FrameLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:clickable="true"
app:layout_anchor="@+id/appbar"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/colorAccent"
android:id="@+id/floatingButtonLog" />
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:我编译:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.jjoe64:graphview:4.2.1'
}
Run Code Online (Sandbox Code Playgroud)
我加入Fragments到FrameLayout用:
infoFragment = new InfoFragment();
infoFragment.setLogs(mapLogIn, mapLogOut, monthToDispaly, yearToDispaly);
infoFragment.setPracownik(mPracownik);
if (getChildFragmentManager().findFragmentByTag("INFO") == null) {
getChildFragmentManager()
.beginTransaction()
.add(R.id.frameForInfo, infoFragment, "INFO")
.commit();
}else {
getChildFragmentManager()
.beginTransaction()
.replace(R.id.frameForInfo, infoFragment, "INFO")
.commit();
}
Run Code Online (Sandbox Code Playgroud)
我如何更换FragmentA使用FragmentB:
((AppCompatActivity)getActivity()).getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frameForFragment, edit)
.addToBackStack(null)
.commit();
Run Code Online (Sandbox Code Playgroud)
怎么我回来从FragmentB到FragmentA:
getFragmentManager().beginTransaction().remove(AddingPerson.this).commit();
if (getFragmentManager().getBackStackEntryCount()>0){
getFragmentManager().popBackStack();
}
Run Code Online (Sandbox Code Playgroud)
看起来NestedScrollView在底部是cuted,因为(如果你看ss)底部没有填充框架.
我注意到当我回来时FragmentA(当显示错误的显示时)我更换了NestedScrollView底部的片段NestedScrollView.
UPDATE
我在这里找到了临时答案.我补充说:
android:layout_gravity="fill_vertical"
android:layout_marginBottom="?attr/actionBarSize"
Run Code Online (Sandbox Code Playgroud)
但有人写道,这个错误在v22.2.1中得到修复,但似乎并非如此.有人知道这件事吗?
| 归档时间: |
|
| 查看次数: |
1524 次 |
| 最近记录: |