logo
down
shadow

How to set width of TouchableWithoutFeedback depends on Text in react-native?


How to set width of TouchableWithoutFeedback depends on Text in react-native?

Content Index :

How to set width of TouchableWithoutFeedback depends on Text in react-native?
Tag : ios , By : tanminivan
Date : November 14 2020, 03:01 PM

I wish this help you It's most likely to do with the container rather than the button itself, check out this snack for example: https://snack.expo.io/@jamie/so-answer.
Component markup
export default class App extends Component {
  render() {
    return (
      <View style={styles.container}>
        <TouchableWithoutFeedback style={styles.button} onPress={() => console.warn('pressed!')}>
          <View style={styles.buttonInner}>
            <Text>Button</Text>
          </View>
        </TouchableWithoutFeedback>
      </View>
    );
  }
}
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
  },

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to set first div width depends on text width, the remaining full width will be assign to second div


Tag : javascript , By : Martin Kopp
Date : March 29 2020, 07:55 AM
like below fixes the issue using flex-box, you can do it like this:
Working Fiddle Tested on: Chrome, IE10, FF (that wht the CSS looks so messy)
    <div class="Row">
        <div class="label"><label>short</label></div>
        <div class="input"><input type="text" value="text goes here" /></div>
    </div>
    <div class="Row">
        <div class="label"><label>this is a long label</label></div>
        <div class="input"><input type="text" value="text goes here" /></div>
    </div>
*
{
    padding: 0;
    margin: 0;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}
.Row
{
    border: 1px solid black;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-direction: normal;
    -moz-box-direction: normal;
    -webkit-box-orient: horizontal;
    -moz-box-orient: horizontal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-box-pack: start;
    -moz-box-pack: start;
    -webkit-justify-content: flex-start;
    -ms-flex-pack: start;
    justify-content: flex-start;
    -webkit-align-content: stretch;
    -ms-flex-line-pack: stretch;
    align-content: stretch;
    -webkit-box-align: start;
    -moz-box-align: start;
    -webkit-align-items: flex-start;
    -ms-flex-align: start;
    align-items: flex-start;
}

    .Row > div
    {
        -webkit-align-self: auto;
        -ms-flex-item-align: auto;
        align-self: auto;
    }

.label
{
    -webkit-box-flex: 0;
    -moz-box-flex: 0;
    -webkit-flex: 0 1 auto;
    -ms-flex: 0 1 auto;
    flex: 0 1 auto;
    /*apply padding if you want*/
}

.input
{
    -webkit-box-flex: 1;
    -moz-box-flex: 1;
    -webkit-flex: 1 0 auto;
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
    /*apply padding if you want*/
}
.input input
{
    width: 100%;
}

How to make a Text take up the entire width with React Native?


Tag : react-native , By : Jarques
Date : March 29 2020, 07:55 AM
will be helpful for those in need make sure the parent has flex style and set the style alignItems : 'center'

width='100%' in react native for images whose native width is smaller than max screen dimensions


Tag : reactjs , By : user107506
Date : March 29 2020, 07:55 AM
To fix this issue Theres a few things you can try.
Try telling the image to cover the screen
resizeMode: 'cover'
alignSelf: 'stretch'
width: null,
height: null

react-native - TouchableWithoutFeedback with ScrollView


Tag : ios , By : Scott Everts
Date : March 29 2020, 07:55 AM
Any of those help I think you should be using keyboardShouldPersistTaps and/or keyboardDismissMode props from ScrollView.
You can read more about that in the docs: https://facebook.github.io/react-native/docs/scrollview.html

Make a background Image disappear from button on button click, TouchableWithoutFeedback - React Native?


Tag : react-native , By : Ben Brown
Date : March 29 2020, 07:55 AM
may help you . This is how you can do it, I have fixed your code. Firstly you need to setState and change state onPress, so that the component re-render and change the image. Simply replace your class with this. Expo Link
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';

const bgImage = require("./assets/BgImage.png");
const mainImage = require("./assets/MainImage.png");

import Button from './Button';

class App extends Component {
constructor(props){
super(props)
this.state = {
  imageVisibility: true,
  backgroundImagePath: require("./assets/BgImage.png")
}
}

  render() {
    return (
      <View style={styles.container}>
          <View style={styles.button}>
             <Button
                backgroundImage={this.state.backgroundImagePath}
                mainImage={mainImage}
                onPress= {() => {this.changeImgaeVisibility()}}
             />
          </View>

      </View>
     );
   }

   changeImgaeVisibility = () => {
   if(this.state.imageVisibility){
       this.setState({imageVisibility: false, backgroundImagePath: null})
   }else{
       this.setState({imageVisibility: true, backgroundImagePath: require("./assets/BgImage.png")})
   }
   }

   }

const styles = StyleSheet.create({
  container: {
    height: 300,
    width: 300,
    justifyContent: 'center',
    alignItems: 'center'
  },
  button: {
    height: 250,
    width: 250,
    alignSelf: 'center',
    position: 'absolute' 
  },
});

export default App;
Related Posts Related QUESTIONS :
  • UISegmentedControl inside UIStackView, segments text not centered - iOS 13
  • Swift & ObjC bridge - cannot find protocol declaration for "WKNavigationDelegate"
  • SwiftUI How to push to next screen when tapping on Button
  • 'NSApp' is unavailable in UIKit for Mac: How to embed Mac only framework in iOS app on macOS?
  • UserDefaults Binding with Toggle in SwiftUI
  • How to create a color with an alpha value using SwiftUI?
  • SwiftUI creates destination views before the user navigates to them
  • Streaming video from https with AVPlayer causes initial delay
  • Tap Action not working when Color is clear SwiftUI
  • SwiftUI NavigationButton: How to navigate to different destinations
  • Supported default light/dark mode colors for Color vs UIColor
  • XCUITest wait for a cell with a specific static text inside it
  • Not able to enable Development mode on iOS 13
  • How to hide the home indicator with SwiftUI?
  • How to write if condition with using label text (Int) values
  • Swift Cannot use instance member within property initializer
  • Issue while getting the frame of the keyboard
  • dynamicMemberLoookup ExpressibleByStringLiteral parameter swift
  • iOS Unity Firebase Messenger Xcode Compile Error: FIRDynamicLinks
  • Firebase Storage Image Cache not updating SWIFT
  • unhandled js exception: application main has not been registered expo TestFlight
  • App freezes on IOS when navigate to another screen - React Navigation
  • How to create haptic feedback for a Button in SwiftUI?
  • How can I achieve automatic scrolling in my text view when text comes down to the keyboard level in Swift?
  • how to get the location with the CLLocationManager every 10 secondes?
  • Calling completion handler of a function from Timer selector function Swift
  • How to make SwiftUI view fullscreen?
  • RAM, JSC, Views, UI and JS usage table appearing whenever I launch my react native app. How to remove this table?
  • Change status bar background color using UIStatusBarManager
  • Should we make tapGesture component an IBAction or IBOutlet to capture the tap event?
  • Iframe automatically goes full screen using Ionic 3.9.2 on iOS
  • How to calculate score out of 1000 given some seconds (In Double)
  • How to calculate time (minutes) between two dates in swift?
  • There was problem loading requested app.it looks like you may be using LAN URL
  • Swift circular corners doesn't work properly on different screen sizes
  • How change .navigationBarTitle font in SwiftUI?
  • What happens if `MPSCNNConvolutionDataSource` protocol's `load` method return false?
  • Why does the UIBarButtonItem not show up when I create it with code?
  • How to prevent following view controller inheriting navigation view controller bar?
  • What does it mean when .xcodeproj files are shown in red in Xcode?
  • Xcode SwiftUI how to scroll the Preview Canvas?
  • Expand tableview and increase scrollview content size by an appropriate difference on clicking a button inside a table c
  • xcodebuild failed with return code: 65 - using CLI/Appcenter but no error messages
  • "'isDeveloperModeEnabled' is deprecated: This no longer needs to be set during development. " What is isDevelo
  • Right click in UIKit for Mac
  • How we Support Dark Mode in Current iOS App with iOS 13?
  • Security vulnerablility issue in ios mobile app
  • How to set a background color for the viewController in swiftUI?
  • SwiftUI : Segue navigation
  • iOS 13 Custom UISearchBar _searchField crash
  • USDZ models have holes in SceneKit but not QuickLook
  • Why does iOS Password Autofill not prompt to save password on keychain?
  • Pushing information to firebase after event is created(Firebase-Realtime-Database)
  • Xcode 11 Beta and Carthage bootstrap
  • How to change the status bar background color and text color on iOS 13?
  • Using Core Data with SwiftUI
  • How should I do to wait all the data downloaded completely and show on TableView?
  • Can we specify the number of rows that can be shown in each section of a collection view
  • Why sometimes completion handler not called?
  • Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com