我知道我的问题有点奇怪,但这是故事背景。我在我的应用程序中添加了一个PreferenceFragment,我正在用SettingsFragment替换主布局中的一个碎片,但我遇到了一个问题:XML内容显示为match_parent,并且显示在工具栏上方,而我希望它显示在工具栏下方。
为什么会发生这种情况?因为碎片布局如下:
我无法更改该片段并将其设置在工具栏下面,否则我会错过我的应用程序的大部分内容(我添加了它的原因)。
所以,简而言之,我的问题是内容重叠了工具栏,我已尝试以下方法:
它起作用了,但是滚动时不起作用,内容会在工具栏上方滚动。
所以,我需要类似于“below:@id/layout”的东西。
有什么想法吗?
为什么会发生这种情况?因为碎片布局如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.abohani.ramadantime.MainActivity">
<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|snap"
android:minHeight="@dimen/abc_action_bar_default_height_material"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
我无法更改该片段并将其设置在工具栏下面,否则我会错过我的应用程序的大部分内容(我添加了它的原因)。
所以,简而言之,我的问题是内容重叠了工具栏,我已尝试以下方法:
<Preference
android:layout="@layout/space"
/>
空间布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/views"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:visibility="invisible"
/>
</RelativeLayout>
它起作用了,但是滚动时不起作用,内容会在工具栏上方滚动。
所以,我需要类似于“below:@id/layout”的东西。
有什么想法吗?