- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的布局基于 Android Studio 创建的内容 - 带有操作栏的空白。这是将我的 fragment_list.xml 扩展为 activity_stats.xml 的默认代码(我只有一个 Java 文件)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_list, container, false);
return rootView;
}
Activity_stats 没有改变,就像 Android Studio 生成的一样。这是 fragment_list.xml
<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"
tools:context="com.company.dummyname.stats$PlaceholderFragment" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clipToPadding="false"
android:paddingTop="@dimen/network_margin_vertical"
android:paddingLeft="@dimen/network_margin_horizontal"
android:paddingRight="@dimen/network_margin_vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/networkContainer"/>
</ScrollView>
</RelativeLayout>
我想将多个 child 添加到 networkContainer。子项应该是来自 network.xml 的布局,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.company.dummyname.stats$PlaceholderFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
grid:columnCount="2" >
<ImageView
android:layout_width="88dp"
android:layout_height="70dp"
android:background="#fff8cdac"
grid:layout_row="0"
grid:layout_column="0"
grid:layout_rowSpan="2"
android:src="@drawable/ic_launcher"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
grid:layout_row="0"
grid:layout_column="1"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9999.99"
android:id="@+id/totalToday"
android:textSize="32sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" today"
android:textSize="32sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="46dp"
android:paddingLeft="8dp"
grid:layout_row="1"
grid:layout_column="1"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9999.99"
android:id="@+id/totalYesterday"
android:textSize="24sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" yesterday"
android:textSize="24sp" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
grid:layout_row="2"
grid:layout_columnSpan="2">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
style="@style/StatsCell" />
<TextView
style="@style/StatsCell"
android:text="Hits" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
style="@style/StatsCell"
android:text="Today"
android:layout_height="match_parent" />
<TextView
style="@style/StatsCell"
android:id="@+id/todayHits"
android:text="9999" />
</TableRow>
</TableLayout>
</android.support.v7.widget.GridLayout>
会有更多的数据和一行,但我删除了它们以简化问题。目标是拥有许多具有不同数据的 network.xml 实例。如何插入它们并更改其中的数据?我在谷歌上做了研究,但没有成功。请忽略硬编码的字符串和尺寸,我会解决的。
编辑:我需要以编程方式添加子项,而不是在 XML 中,因为 network.xml 实例的数量会因用户设置而异。
最佳答案
在 XML 中
要包含多个布局,您应该使用 include父布局中的元素引用子布局
在代码中(以编程方式)
在获取根 View
的 onCreateView
函数中,尝试像这样获取容器布局
LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.networkContainer);
然后在该线性布局中创建并添加您要添加的其他 View 的实例,如下所示获取子布局的 View 使用 LayoutInflator
layout.addView(newView);
最后返回父 View
关于android - 将多个子布局从 XML 文件添加到另一个布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21966593/
我试图四处移动一些 div,但我似乎无法通过对象对象选择它们: http://jsfiddle.net/kL3c8/1/ 1 2
我在 WP 网站上使用 Ninja Forms。有 2 个不同的字段(文本框和提交按钮)是单独的 DIV,它们都是单个 DIV 的子项。 它们出现在连续的行上,但我似乎无法在同一行上找到它们。帮忙?
我专门针对第 n 个 child (2n),但是具有给定类的 sibling 的第一个、第三个等应用了 css。 http://jsfiddle.net/relitnosmoge/9HCnH/1/ .
我有一个页面可以引入数据库条目并显示它们,并且我已经为所有其他条目/列表提供了这种样式: hjl:nth-child(odd) { background: #F2F2F2;} 这是我的 HTML/PH
我正在显示每个字母具有相同背景(宽度 31px )的字母表。我需要一半的字母宽度为 30px。这由以下人员处理: div.alpha:nth-child(even) {width: 30px;} 但是
我需要从一些大的嵌套字典中获取一些值。出于懒惰,我决定编写一个递归调用自身的函数,直到找到最后一个 child ,或者叶子为空。 由于会弹出字典,并且每次调用都会生成一个新字典,我想知道这有多有效。
我有 2 个 css 类 leftColumn 和 rightColumn 排列在 React SPA 的行布局中。问题在于,当浏览器变窄时,rightColumn 会在 leftColumn“下方”
我有这个 fiddle ,我想在默认情况下仅显示第一张照片并隐藏其余照片,并通过每次鼠标滚动更改照片。 var i 由 mousescroll 确定,如果 i 5,我希望操作中断,因为没有第 n 个
我有一个父 div 和 2 个嵌套的子 div。当第二个子 div 不包含任何内容时,我想隐藏第一个子 div 和父 div。我想知道如何做到这一点? 我有 2 个子 div 的原因是因为我正在创建一
我有一个父 div 和 2 个嵌套的子 div。当第二个子 div 不包含任何内容时,我想隐藏第一个子 div 和父 div。我想知道如何做到这一点? 当 .portfolio-works-conta
我注意到在我的浏览器中,SSL 证书链始终至少有 2 个子 CA。总是这样吗?如果属实,有人知道为什么吗? 最佳答案 通常至少有一个中间 CA,因为它可以更轻松地管理子公司和管理滚动,但这不是必需的。
我在让交叉淡入淡出动画停止在最后一个子节点上时遇到了一些麻烦。我知道 animation-fill-mode: forwards ,但它似乎不起作用(我试过将它放在不同的地方,例如在最初的 .cros
我想水平对齐 3 个不同的子 div。这 3 个 div 包含 1 个图像(高度和宽度 px)。每个 div 都有一个悬停链接(但我希望我的 onmouseover 仅位于图像上方,而不是位于 div
我正忙于 Bigcommerce 网站的设计,发现列表项及其各自背景存在 css 语法问题。 列表项标题和列表项本身是从数据库生成的。这是我的代码的样子: .Left #SideCategoryLis
所以我有一个父 div(100% 宽度)和其中的 3 个子 div(也是 100% 宽度)。我如何将“默认显示的 div”设置为第二个子元素,以便左侧 div 向左离开屏幕,而右侧 div 向右离开屏
我正在尝试将 vector 拆分为 n 个部分。我检查了以下解决方案 How to split a vector into n "almost equal" parts 我根据这个评论得出了以下代码:
下面是我的div: Abc pqr function AppendDiv(10,11) { var eFrom = $('#' + 10); var toD
我试图让我的 html 页面与 JSF 一起工作,并且偶然发现了一个问题,即如何让 nth-child css 选择器与 jsf 一起工作 repeat标签?现在,对于 repeat 标签生成的每个元
这个问题在这里已经有了答案: How do you keep parents of floated elements from collapsing? [duplicate] (15 个答案) 关闭
试图整理我的 CSS,一团糟,我有许多 ID 分布在 div 和子 div 中,以便我能够在 CSS 中选择它们。 我想知道这样做的正确方法是什么? 我考虑过使用类,这似乎是一种更好的方法,但仍然在每
我是一名优秀的程序员,十分优秀!