Sha*_*lin 4 android android-layout android-studio
我将手机升级为Marshmallow后,我所制作的所有应用都将其操作栏切断.该应用程序在Lollipop和Kitkat上工作正常.
该应用程序基本上有一个视图,它在我更新的手机上没有正确显示.
上半部分切断了
activity_main.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.shalin.clickme.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
content_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.shalin.clickme.MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
android:onClick="switchButtons"
android:id="@+id/button1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text=""
android:onClick="switchButtons"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentEnd="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:我尝试了android:fitsSystemWindows,这就是我得到的: 使用android:fitsSystemWindows
android:fitsSystemWindows="true"
在布局的根视图中使用.
并且a android:fitsSystemWindows
是一个内部属性,用于根据系统窗口(如状态栏)调整视图布局.如果为true,则调整此视图的填充以为系统窗口留出空间.仅在此视图位于非嵌入活动中时才会生效.
您也可以通过在主题中设置为全局来设置它
<item name="android:fitsSystemWindows">true</item>
归档时间: |
|
查看次数: |
2759 次 |
最近记录: |