Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 隐藏在ToolBar后面的ListView,以及隐藏在ListView后面的浮动操作按钮大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_944_2@
我的FAB将显示android studio的设计窗口中,但在我实际运行应用程序时不显示.

另外,我有一个ListView项目,我指定它应该位于工具栏下方,但是当我运行应用程序时,它部分隐藏在工具栏后面.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://scheR_290_11845@as.android.com/apk/res/android"
xmlns:app="http://scheR_290_11845@as.android.com/apk/res-auto"
xmlns:tools="http://scheR_290_11845@as.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:BACkground="?attr/colorPriMary"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<ListView
    android:id="@+id/android:list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layouT_Below="@+id/my_toolbar" />

<at.markushi.ui.CircleButton
    android:layout_width="64dp"
    android:layout_height="64dp"
    app:cb_color="@color/colorPriMary"
    app:cb_pressedRingWidth="8dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentright="true"
    android:onClick="openEditorForNewNote"
    android:src="@drawable/ic_action_add"/>

</RelativeLayout>

how the layout appears in design mode

how app appears when run

做什么?

@H_944_2@

解决方法

尝试在代码中将FAB移动到ListView上方,如下所示:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://scheR_290_11845@as.android.com/apk/res/android"
xmlns:app="http://scheR_290_11845@as.android.com/apk/res-auto"
xmlns:tools="http://scheR_290_11845@as.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:BACkground="?attr/colorPriMary"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<at.markushi.ui.CircleButton
    android:layout_width="64dp"
    android:layout_height="64dp"
    app:cb_color="@color/colorPriMary"
    app:cb_pressedRingWidth="8dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentright="true"
    android:onClick="openEditorForNewNote"
    android:src="@drawable/ic_action_add"/>

<ListView
    android:id="@+id/android:list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layouT_Below="@+id/my_toolbar" />
</RelativeLayout>

基本上,Android会根据XML标记中的顺序以特定顺序呈现布局.

将listView的高度更改为wrap_content(我在上面的代码中将其更改为如此,但这里又是):

<ListView
    android:id="@+id/android:list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layouT_Below="@+id/my_toolbar" />

因为ListView是工具栏的兄弟,所以当高度设置为match_parent时,它会填满整个屏幕,包括工具栏下的区域.

@H_944_2@ @H_944_2@
@H_944_2@
@H_944_2@

大佬总结

以上是大佬教程为你收集整理的android – 隐藏在ToolBar后面的ListView,以及隐藏在ListView后面的浮动操作按钮全部内容,希望文章能够帮你解决android – 隐藏在ToolBar后面的ListView,以及隐藏在ListView后面的浮动操作按钮所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。