Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29454

React-Native Native UI component doen't resize (Android)

$
0
0

I have issues with React Native respecting the height of an Android Native UI Component. I have created a very simple use-case to demonstrate the issue.

React Native version = 0.61.5.

Android, React Native ViewManager:

public class CustomTextViewManager extends SimpleViewManager<TextView> {    @NonNull    @Override    protected TextView createViewInstance(@NonNull ThemedReactContext reactContext) {        return new TextView(reactContext);    }    @NonNull    @Override    public String getName() {        return "CustomTextView";    }    @ReactProp(name = "text")    public void setText(TextView view, String text) {        view.setText(text);    }}

JavaScript, native view reference:

import {requireNativeComponent} from 'react-native';const CustomTextView = requireNativeComponent('CustomTextView')export default CustomTextView;

JavaScript, simple app:

import React from 'react';import CustomTextView from './CustomTextView';const App: () => React$Node = () => {  return (<CustomTextView      text={'Some test text'}    />  );};export default App;

When you run this code nothing is shown. After adding style={{height: 100}} the view is shown at the provided fixed height.

I actually expected that the height of the Android View would be reflected in React Native. Apparently this is not the case.

Note: height: "auto" doesn't work.I hope that someone can tell me what I'm missing.


Viewing all articles
Browse latest Browse all 29454

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>