Mat*_*ias 9 android android-fragments android-coordinatorlayout
看看下面的布局.你会看到浮动按钮距离底部太远.这是因为显示了工具栏和选项卡,并且ViewPager的高度错误.所以我在某种程度上对layout_height做错了.但是我该如何解决这个问题呢?
备注:ViewPager是主要内容,它包含第二个选项卡中带有ListView和Google Map V2的片段.
这是布局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"
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:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<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" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager_list_views"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="fill_parent">
</android.support.v4.view.ViewPager>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是第一个选项卡(列表)中片段的布局:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/preview_list"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:orientation="vertical" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/action_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="@mipmap/ic_add_white_48dp" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
只想确认一下; 这对FAB来说不是问题.看到这张照片.这是一个类似的布局.带有ToolBar和ViewPager的CoordinatorLayout,可以浏览所有细节条目(因此不需要选项卡).而且,内部视图似乎太长(与ToolBar的高度相同).
compile 'com.android.support:recyclerview-v7:23.0.0'
在 build.gradle 依赖项中声明。我遇到了同样的问题,即视图页面与系统按钮重叠。我通过简单地添加此依赖项来修复它。 归档时间: |
|
查看次数: |
3949 次 |
最近记录: |