React Native ScrollView縮放


"use strict"

import React, { Component } from 'react';
import {
AppRegistry, // 注冊組件,是應用的JS運行入口
StyleSheet, // 樣式表, 類似於一個集合包含各個組件的屬性
ScrollView,
Dimensions, // 規格
TouchableWithoutFeedback,
Image, // 圖片組件
View // 視圖組件
} from 'react-native';

const { width, height } = Dimensions.get('window')

// 聲明一個 Helloworld 組件
class HelloWorld extends Component {

render() { // 渲染

return (

<ScrollView contentContainerStyle={{flex: 1}} // 默認充滿整個空間(屏幕)
maximumZoomScale={2} // 子組件(圖片)放大倍數
minimumZoomScale={1.0} // 子組件(圖片)縮小倍數
showsHorizontalScrollIndicator={true}
showsVerticalScrollIndicator={true}
centerContent={true} // 子組件(圖片)一直處於父組件中心位置,不會因縮放向其他方向偏離
ref="testScroll"
>
<TouchableWithoutFeedback onPressOut={this.sigleTap()}>
<Image source={require('./Resource/Test/ttttt.png')}
resizeMode={'contain'}
style={{flex: 1, width, height}} // 如果Image不設置width、height那么他就會按照自身的大小就行展示,導致超出屏幕邊界
/>
</TouchableWithoutFeedback>
</ScrollView>
);
}

sigleTap() { // 手勢這個暫未搞明白
var timestamp = new Date().getTime(); // 時間戳

alert(timestamp)

}

}

    

 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM