React Native Androidでボタンの高さを設定する方法 質問する

React Native Androidでボタンの高さを設定する方法 質問する

私は Android モバイル アプリ用の React Native プログラミングを学習しています。高さを設定する必要がある画面を作成していますが、スタイルを使用して高さをbutton.追加して設定しましたが、ボタンの高さは変更されません。buttonview

/**
 * LoginComponent of Myntra
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from "react";
import { AppRegistry, Text, View, Button, TextInput } from "react-native";

class LoginComponent extends Component {
render() {
    return (
        <View style={{ flex: 1, flexDirection: "column", margin: 10 }}>
            <TextInput
                style={{
                    height: 40,
                    borderColor: "gray",
                    borderWidth: 0.5
                }}
                placeholder="Email address"
                underlineColorAndroid="transparent"
            />

            <TextInput
                style={{
                    height: 40,
                    borderColor: "gray",
                    borderWidth: 0.5
                }}
                placeholder="Password"
                secureTextEntry={true}
                underlineColorAndroid="transparent"
            />

            <View style={{ height: 100, marginTop: 10 }}>
                <Button title="LOG IN" color="#2E8B57" />
            </View>
        </View>
    );
  }
}

AppRegistry.registerComponent("Myntra", () => LoginComponent);

要件に応じてボタンの高さを設定するのを手伝ってくれる人はいますか?

ベストアンサー1

このコンポーネントにはオプションが限られているため、固定サイズにサイズを変更することはできませんheight

TouchableOpacity独自のボタンを作成するには、コンポーネントを使用し、独自のpropertiesおよび を使用することをお勧めしますstyles

次のように簡単にスタイルを設定できます。

<TouchableOpacity style={{ height: 100, marginTop: 10 }}>
    <Text>My button</Text>
</TouchableOpacity>

おすすめ記事