Как центрировать текст в Facebook, кнопка входа в React Native (Android)? - PullRequest
0 голосов
/ 04 июня 2018

Я использую кнопку входа Facebook SDK (через react-native-fbsdk) в моем приложении React-Native.

Текст кнопки Continue with Facebook отображается по центру в iOS, но не в центре в Android (7.0).

Это моя единственная возможность создать собственную кнопку, которая вызывает LoginManager вручную,или есть способ выровнять текст, используя стили (я пробовал alignItems и justifyContent)?Кажется, что я должен сделать первый, основанный на этот вопрос SO .

Это мой код на данный момент:

<LoginButton
   scope={'public_profile email'}
   style={{
       width: 220,
       height: 40
   }}
   onLoginFinished={this._facebookLogin}
   onLogoutFinished={() => console.log('logout.')}
/>

Photo of misaligned text

1 Ответ

0 голосов
/ 30 апреля 2019

Вы можете обернуть кнопку в контейнер

<View style={{
  width: 220, // whatever you want
  height: 50, // whatever you want
  justifyContent: 'center', // center the button
  backgroundColor: '#4267B2', // the same as the actual button
  paddingHorizontal: 10 // optionally add some horizontal padding for better looking
}}>
  <LoginButton
    scope={'public_profile email'}
    style={{
       flex: 1, // fill the container
       maxHeight: 30 // the default height
   }}
   onLoginFinished={this._facebookLogin}
   onLogoutFinished={() => console.log('logout.')}
  />
</View>

Результаты

enter image description here

...