title: Set opacity's volume onPress of TouchableOpacity manually in React-Native
body: <p>I am trying to figure out how to change the volume of the opacity of TouchableOpacity component of React-Native, meaning that I do not like the default value of the opacity when the press is performed, and I would like the opacity to be less transparent.</p>
  
  <p>According to the <a href="https://facebook.github.io/react-native/docs/touchableopacity.html" rel="noreferrer">documentation</a> for this purpose the <a href="https://facebook.github.io/react-native/docs/animated.html" rel="noreferrer">Animated API</a> should be used:</p>
  
  <blockquote>
    <p>Opacity is controlled by wrapping the children in an Animated.View, which is added to the view hierarchy. Be aware that this can affect layout.</p>
  </blockquote>
  
  <p>So, I did it, that's how it looks:</p>
  
  <pre><code>&lt;Animated.View style={{ opacity: this.state.opacity._value }}&gt;
      &lt;TouchableOpacity 
          onPress={this.hideKeyboard.bind(this)}
          style={{ opacity: this.state.opacity._value }}
      &gt;
          &lt;Text style={buttonTextStyle}&gt;Cancel&lt;/Text&gt;
      &lt;/TouchableOpacity&gt;
  &lt;/Animated.View&gt;
  </code></pre>
  
  <p>The <strong>hideKeyboard</strong> method, that is being invoked onPress, calls the <strong>changeOpacity</strong> method from within it, that's how it looks:</p>
  
  <pre><code>changeOpacity() {
      Animated.timing(
          this.state.opacity, 
          {
              toValue: this.state.opacity === 1 ? 0 : 1,
              duration: 500
          }
      ).start();
  }
  </code></pre>
  
  <p><strong>this.state.opacity</strong> is declared in the constructor:</p>
  
  <pre><code>constructor(props) {
      super(props);
      this.state = { opacity: new Animated.Value(1) };
  }
  </code></pre>
  
  <p>Having all of this, the behavior (the volume of the opacity onPress of TouchableOpacity) does not change, it is still stays default. The documentation also vaguely introduces setOpacityTo method, but I can't figure out how to use it due to the thoroughness of the description provided in the documentation. How can I perform a manual configuration of the opacity?</p>