Skip to content

Commit 355d1fe

Browse files
committed
android: Make minWidth of TextInput 0 like iOS.
Currenlty TextInput on Android has some default minWidth, but on iOS it is 0. So this commit makes TextInput width consistent on both the platform. On Android, if no text is present and no placeholder is provided, it's width is 0 (assuming padding: 0 style is applied). But as soon as a single char is entered in the input, it width becomes more than that of char. It is no more WRAP_CONTENT. This commit fixes it. Note: Setting backgroundColor has no affect on TextInput background color, as background color is handled by backgroundManger. Before: https://user-images.githubusercontent.com/39303760/43045548-252fae7a-8dd8-11e8-8948-bb37c2b0689e.png After: https://user-images.githubusercontent.com/39303760/43045549-255c3bac-8dd8-11e8-8b12-30f413777544.png Testing code: https://github.com/jainkuniya/TestTextInput/blob/3bd6d6621d20bb6f13ede84e63e6948963febc9b/App.js
1 parent e592d6f commit 355d1fe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package com.facebook.react.views.textinput;
99

10+
import android.graphics.Color;
1011
import android.os.Build;
1112
import android.text.SpannableStringBuilder;
1213
import android.util.TypedValue;
@@ -48,6 +49,7 @@ public void apply(EditText editText) {
4849
editText.setMinLines(mMinLines);
4950
editText.setMaxLines(mMaxLines);
5051
editText.setInputType(mInputType);
52+
editText.setBackgroundColor(Color.TRANSPARENT);
5153
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
5254
editText.setBreakStrategy(mBreakStrategy);
5355
}

0 commit comments

Comments
 (0)