非常教程

React native参考手册

Components: TouchableNativeFeedback

TouchableNativeFeedback

用于使视图正确响应触摸的包装(仅限Android)。在Android上,此组件使用本机状态drawable来显示触摸反馈。

目前它仅支持将单个View实例作为子节点,因为它通过用一些附加属性设置替换该视图与另一个RCTView节点实例来实现。

可触摸的本地反馈的背景可以根据background属性进行定制。

例:

renderButton: function() {
  return (
    <TouchableNativeFeedback
        onPress={this._onPressButton}
        background={TouchableNativeFeedback.SelectableBackground()}>
      <View style={{width: 150, height: 100, backgroundColor: 'red'}}>
        <Text style={{margin: 30}}>Button</Text>
      </View>
    </TouchableNativeFeedback>
  );
},

属性

TouchableWithoutFeedback属性...

background?: backgroundPropType

确定将用于显示反馈的背景可绘制类型。它需要一个具有type属性和额外数据的对象,具体取决于type。建议使用其中一种静态方法来生成该字典。

useForeground?: bool

设置为true可将纹波效果添加到视图的前景,而不是背景。如果您的某个子视图具有其自己的背景,或者您正在显示图像,并且您不希望波纹被它们覆盖,这非常有用。

首先检查TouchableNativeFeedback.canUseNativeForeground(),因为这仅适用于Android 6.0及更高版本。如果您尝试在旧版本中使用此功能,您将收到警告并回退到背景。

方法

static SelectableBackground()

创建一个代表android主题默认背景的可选元素的对象(?android:attr / selectableItemBackground)。

static SelectableBackgroundBorderless()

创建一个表示android主题的无边界可选元素的默认背景(?android:attr / selectableItemBackgroundBorderless)的对象。适用于Android API级别21+。

static Ripple(color: string, borderless: boolean)

创建一个表示用指定颜色绘制波纹的对象(作为字符串)。如果属性borderless评估为true,则纹波将呈现在视图边界之外(请参阅本机操作栏按钮作为该行为的示例)。此背景类型可在Android API级别21+上使用。

参数:

名称和类型

描述

colorstring

波纹的颜色

borderlessboolean

如果涟漪可以渲染到它的边界之外

static canUseNativeForeground()

Components: TouchableNativeFeedback相关

React native

React Native 是一个 JavaScript 的框架,用来撰写实时的、可原生呈现 iOS 和 Android 的应用。

主页 https://facebook.github.io/react-native/
源码 https://github.com/facebook/react-native
发布版本 0.49

React native目录

1.开始 | Getting Started
2.指南 | Guides
3.APIs
4.组件:ActivityIndicator | Components: ActivityIndicator
5.组件:按钮 | Components: Button
6.组件:CheckBox | Components: CheckBox
7.组件:DatePickerIOS | Components: DatePickerIOS
8.组件:DrawerLayoutAndroid | Components: DrawerLayoutAndroid
9.组件:FlatList | Components: FlatList
10.组件:图像 | Components: Image
11.组件:KeyboardAvoidingView | Components: KeyboardAvoidingView
12.Components: ListView
13.Components: MaskedViewIOS
14.Components: Modal
15.Components: NavigatorIOS
16.Components: Picker
17.Components: PickerIOS
18.Components: ProgressBarAndroid
19.Components: ProgressViewIOS
20.Components: RefreshControl
21.Components: ScrollView
22.Components: SectionList
23.Components: SegmentedControlIOS
24.Components: Slider
25.Components: SnapshotViewIOS
26.Components: StatusBar
27.Components: Switch
28.Components: TabBarIOS
29.Components: TabBarIOS.Item
30.Components: Text
31.Components: TextInput
32.Components: ToolbarAndroid
33.Components: TouchableHighlight
34.Components: TouchableNativeFeedback
35.Components: TouchableOpacity
36.Components: TouchableWithoutFeedback
37.Components: View
38.Components: ViewPagerAndroid
39.Components: VirtualizedList
40.Components: WebView
41.创建 | Contributing
42.指南(Android) | Guides (Android)
43.指南(IOS) | Guides (iOS)
44.其他 | Miscellaneous