- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在玩弄 iosched来自 Google I/O 2011 的应用程序。查看 ScheduleFragment,我在 Workspace 上测试不同的 View children 来回翻动书页。但是,我无法让我的 child 的观点来填充 parent 。我添加了几种背景颜色和一些填充以显示所有内容的布局。这是我的测试...
我像这样在 fragment_schedule.xml 中的“工作区”项中添加了红色背景色...
android:background="#cc0000"
然后,我没有为 subview 使用 blocks_content.xml,而是创建了自己的 pending_content.xml,它只是一个绿色背景的 LinearLayout(高度为 fill_parent)和一个蓝色背景的 TextView(高度也为 fill_parent)用一个简单的文本行。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00cc00"
android:padding="5dip"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/text_view"
android:background="#0000cc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Pending Content"
android:textColor="#ffffff"
/>
</LinearLayout>
我添加我的 View 就像 I/O 应用程序有“天”...
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_schedule, null);
mWorkspace = (Workspace) root.findViewById(R.id.workspace);
ShootView view = new ShootView();
view.index = mViews.size();
view.rootView = (ViewGroup) inflater.inflate(R.layout.pending_content, null);
view.label = "Pending";
mWorkspace.addView(view.rootView);
mViews.add(view);
这是我在设备上查看时看到的内容:
您会看到红色的 Workspace 填充了可用的父空间,但绿色的 LinearLayout 没有。我错过了什么?
最佳答案
问题是在你的通货膨胀步骤中:
view.rootView = (ViewGroup) inflater.inflate(R.layout.pending_content, null);
您丢失了在 XML 中定义的 LayoutParams
,您的 View 实际上以默认布局参数结束。
您需要做的是提供一个 root
并且在充气期间不要将充气布局附加到根:
view.rootView = (ViewGroup) inflater.inflate(R.layout.pending_content, mWorkspace, false);
这将允许布局 inflater 从解析的 XML 属性为您的 subview 构造一组适当的 LayoutParams
。
关于android - "Workspace" subview 未在 Google "iosched"应用程序上填充高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6229594/
3 周前,我下载了 Google iosched 源代码并将其导入到我的 android studio 中。我可以在我的模拟器以及连接到我的机器的设备中安装和运行该应用程序。然而,上周,当我尝试运行同
使用向上和向后按钮导航非常复杂(至少对我而言)正如 android 文档所述, You have the ability to make the Up behavior even smarter ba
我一直在寻找 Google iosched 2014 应用程序,以确保我遵循 Material 设计的正确设计模式,特别是支持 v7 库和 appcompat v21 的 pre-L 设备。 为了使用
我正在使用来自 code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/widge
我这样做是为了将 noop-iosched.c 编译为内核模块。但是,当我尝试执行 insmod noop-iosched.ko 时,它会导致段错误。我不明白为什么会这样。当我列出模块时,它出现在那里
下载Google IO 2018(iosched)的工程,在Android Studio 3.3 Canary 7中尝试编译,也在3.2 RC1中进行probe。但是我收到以下错误: error: r
我正在尝试使用 Google iosched 作为引用项目来学习 Android UI 设计的最佳实践。 为了在 Eclipse 上设置和运行源代码,我需要遵循哪些步骤 最佳答案 ECLIPSE:文件
我正在玩弄 iosched来自 Google I/O 2011 的应用程序。查看 ScheduleFragment,我在 Workspace 上测试不同的 View children 来回翻动书页。但
我已经下载google iosched存储库并遵循 build instructions但是当我跑的时候 ./gradlew clean assembleDebug 我收到这个错误: Info
我是一名优秀的程序员,十分优秀!