0

TouchableOpacity を介してネイティブに反応するカスタム ボタンを設計しています。これまで、さまざまなスタイリング アプローチを試してきましたが、必要なデザインにはなりませんでした。以下は、解決しようとする私の試みです。

<TouchableOpacity style={styles.numericButton}>
      <View>
          <Text style={styles.numericButtonText}>1</Text>
      </View>
</TouchableOpacity>


const styles = StyleSheet.create({

    numericButton: {
        margin:10,
        padding:10,
        backgroundColor:'#D3D3D3',
        borderColor:'#000',
        borderWidth:2,
        borderRadius:5,
        elevation:10,
        shadowOffset: { width: 5, height: 5 },
        shadowColor: "black",
        shadowOpacity: 1,
        shadowRadius: 5,

    },
    numericButtonText:{
        fontSize:24,
        fontWeight:'bold',
        fontFamily:'Cochin'
    }
});

結果:

出力画像

このように反応するネイティブボタンのスタイルを設定したい

ここに画像の説明を入力

4

2 に答える 2

0

react-native-linear-gradientで同じタイプのボタンを実現できます

ここに画像の説明を入力

以下で達成されました:

            <TouchableOpacity>
                <LinearGradient
                    // start={{x: 0.5, y: .5}} end={{x: 1, y: 1.0}}
                    style={styles.button}
                    locations={[0.3, 0, 0]}
                    colors={['#A8AFB5', 'white', 'white']}
                >
                     <Text style={styles.buttonText}>{props.data}</Text>
                </LinearGradient>
            </TouchableOpacity>




 const styles = StyleSheet.create({

    button: { flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', borderRadius: 5, width: null, height: 81,marginTop:5, borderWidth: 1 },
    buttonText: {
        //textAlign:'center',
        fontSize: 24,
        fontWeight: 'bold',
        fontFamily: 'Cochin',
        color: 'black'
    }
});
于 2019-02-11T09:25:44.080 に答える