- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我不熟悉抽屉布局和 fragment 的使用。
我使用了 tutorial关于使用 DrawerLayout
创建 Activity 。它在 getActionBar()
上给了我一个空指针,所以我添加了 a toolbar到主要 Activity 并使用 getSupportActionBar()
代替。
现在看起来工具栏充满了整个屏幕,因为标题在屏幕中间,工具栏的背景也在整个屏幕上。这是 xml 代码:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Toolbar -->
<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:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFFFFF"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
我试过用 56dp 替换 layout_height 并且我试过制作一个单独的布局文件,其中包含工具栏并将其包含到这个 xml 中,但这没有用。
为什么我的工具栏会填满整个屏幕?
最佳答案
DrawerLayout
需要 2 个 View 。你提供 3 个。
第一个 View 是“背景”。它是屏幕的内容。第二个 View ,抽屉,应该以动画方式进出。
您提供了 3 个 View 。所以您的工具栏就是“内容”——因此是全屏,而您的抽屉就是您的实际内容。
要解决您的问题,请尝试以下操作:
<DrawerLayout>
<!-- The main content view -->
<LinearLayout>
<Toolbar/>
<FrameLayout
android:id="@+id/content_frame"/>
</LinearLayout>
<!-- The navigation drawer -->
<ListView/>
</DrawerLayout>
关于android - 工具栏填满整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38805119/
我正在运行 Play! 2.3 使用 Akka 的多线程应用程序。每个线程访问 MySQL 数据库并运行一些计算。每次我运行一组这样的任务时,应用程序的内存占用量都会增加,这主要是由于 JDBC4Pr
我是 JavaScript 新手,正在尝试实现选择排序来亲自接触数组(注意:我知道有一个内置的排序函数)。不过,我遇到了一些奇怪的行为。 这是我的代码: function selectionSort(
我正在使用 unsemantic grid创建我的布局。好吧,我有一个容器,其中有一个标签和一个输入文本。标签的宽度为 20% 然后 margin-rightof 1em 然后我想让容器中的其余空间由
看看这张取自 morsmachine.dk/go-scheduler 的著名图片 灰名单是 P 的本地运行队列。如果此队列变空,它们将被全局运行队列中的 go routines 填充。 问题是,谁来填
(帖子创建于 2016 年 10 月 5 日) 我注意到每次运行图像并删除它时,我的系统都不会恢复到原来的可用空间量。 我应用于容器的生命周期是: > docker build ... > docke
我有一个应用程序,它在启动时运行两个或三个完整的 GC。有很多堆空间,不需要运行任何 GC(minor 或 full)。然而,在 gc 日志中,我可以看到 permgen 被填满,然后立即运行完整
我正在尝试制作可视化 VStack 属性的 VStack 示例应用 但是我的 VStack 无法填满屏幕的宽度 我在互联网上尝试了很多解决方案(frame modifier、HStack with S
[已解决] 所以我在页面顶部有一个高度恒定的 div,我希望在它下面有一个 iFrame 来填充页面的其余部分。 Google Images 和 LinkedIn 做的事情非常相似 参见:http:/
我正在尝试使我的标题框与我的图像大小相同,同时又不失去 flex-slider 的响应能力,有什么建议吗? http://jsfiddle.net/bmBnF/10/ 疯狂的K 最佳答案 我通过将其设
我有一个元素是 的兄弟元素动态填充 hello 我想要 固定在屏幕底部直到动态 s 要求将其向下推到 View 下方。 我尝试了以下但无法获得我想要的结果。 该元素位
我是一名优秀的程序员,十分优秀!