- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我知道 React Native 中有一个“View”组件,它的行为类似于 Android VieGroup,但它更有可能作为 LinearLayout 工作 - 子项按行或列排列。
我想知道如何实现“FrameLayout”行为 - 子元素堆叠在布局中,并且可以为每个子元素分配一个唯一的重力位置。
例如:将 5 个子元素放入一个组件中,4 个子元素中的每一个都与布局的每个角对齐,最后一个子元素与布局的中心对齐。
如何编写 React Native 的“渲染”功能?
最佳答案
这可以使用 position: 'absolute' 并将其对齐 top,left,right,bottom 属性来完成。这是一个工作示例
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
var SampleApp = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.topLeft}> Top-Left</Text>
<Text style={styles.topRight}> Top-Right</Text>
<Text>Center</Text>
<Text style={styles.bottomLeft}> Bottom-Left</Text>
<Text style={styles.bottomRight}> Bottom-Right</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
marginTop: 24
},
topLeft:{
position: 'absolute',
left: 0,
top: 0
},
topRight:{
position: 'absolute',
right: 0,
top: 0
},
bottomLeft:{
position: 'absolute',
left: 0,
bottom: 0
},
bottomRight:{
position: 'absolute',
right: 0,
bottom: 0
}
});
AppRegistry.registerComponent('SampleApp', () => SampleApp);
也在 rnplay 上,https://rnplay.org/apps/n6JJHg
关于android - 如何在 React Native 中实现 'FrameLayout' 组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37406960/
我正在尝试使用 RelativeLayout 扩充 FrameLayout。然后我像这样扩展一个 FrameLayout: public class Keyboard extends FrameLay
在我的应用程序中,我有一个布局,它有一个 RelativeLayout 我想在运行时以编程方式设置边距。但是当我这样做时,它给了我 ClassCastException 说 FrameLayout 不
我在横向模式下的 FrameLayout 中打开 android Camera,然后屏幕看起来像- 但是当我在 FrameLayout 中的 ImageView 中打开相同的图像时,它看起来像 - 请
我在画廊中使用了 FrameLayout 作为画廊项目。 FrameLayout 中有 2 个 RelativeLayouts,每个都有一些 TextView 和一个 ImageView。图库外有一个
我目前正在使用 xml 为 Activity 创建布局,内容 (FrameLayout) 应该填满整个屏幕。不幸的是,事实并非如此。只有当我将边距更改为以下时,它才有效: 左:-17dp 右:-19d
我有一个 View (假设它是 MyFramLayout)扩展了 FrameLayout,我无法在按下键时让这个 FrameLayout 获得焦点(我在电视平台上工作)。 布局是这样的:
我正在尝试设置一个平板电脑布局,左侧是一个列表,右侧是一个详细信息 Pane 。单击列表项时,详细信息 Pane 将填充一系列比左侧列表更长的卡片。我希望详细信息 Pane 和列表(回收站 View
我用按钮创建了一个布局,这个按钮有逻辑,我不想集成它。 所以我认为: 当我有按钮时,我需要添加一个 char $,所以我创建了一个 frameLayout 并在此处添加了一个 TextView,我这样
我正在使用 FrameLayouts 在图像上重叠图像,但在这种特殊情况下我无法理解我的内部 FrameLayout 没有显示在另一幅图像的前面。这是理论: 这是实际的事情: 这是我的 XML:
在 FrameLayout 中,我动态添加了一个 WebView,用于在旋转屏幕时保存内容,但事实并非如此,情况是在 FrameLayout 下面我想放置一个固定的页脚。下一个代码放置页脚,但 Fra
我在加载 fragment Activity 时意外收到空指针异常错误。我指的是 FrameLayout 将用户定向到另一个 Activity (在单击按钮时)。 11-10 07:31:58.773
我想测试使用 fragment 管理器动态替换 fragment 。在主布局中,在父衬里布局下,我有 3 个布局,一个子线性布局和 2 个子框架布局。这个想法是在第一个子线性布局中使用一个按钮来交换第
我正在开发 Android 即时聊天应用程序。在聊天 Activity 中,我正在使用 FrameLayout。以下是 xml 文件: 我已将框架的可见性设置为
这是有效的: a) main.xml 中带有两个 ImageView 的 FrameLayout b) 在背景上旋转动画,而前景部分保持不变 因为我需要对背景图像做更多的工作,
我有以下问题:我有很长的 ListView,但是当我向上滚动时会触发 onRefresh,而不是先滚动回顶部。我该如何解决这个问题? 我将以下 fragment 插入到 FrameLay
我有一个 FrameLayout,上面显示了一个 LinearLayout我的 Intent 是这个 LinearLayout 总是占据屏幕的 33%……但我做不到。我尝试使用“dp”,但当然,结果因
是否有一种布局,其中的项目可以像 Android 的 FrameLayout 一样分层放置? 我已经在谷歌上搜索了一段时间,但找不到类似的东西。 最佳答案 我希望这个答案很清楚并且可以帮助您。您需要的
我是第一次使用 NavigationBar 小部件,我无法将 FrameLayout 设置为不在 NavigationBar 后面。我已经尝试了一切:在 RelativeLayout 中设置(Navi
我有以下 View 层次结构: 我尝试设置 ImageView 的下边距,在布局编辑器上它似乎工作正常,但是当我运行代码时,我设置的下边距被丢弃了。
我有这样的布局: 相对布局 框架布局 fragment (谷歌地图图层) 复选框 ...其他按钮和东西 现在我想在选中 Checkbox 时捕获 FrameLayout 上的触摸事件。我用 dispa
我是一名优秀的程序员,十分优秀!