Comments (52)
Hey, which Android version are you running on the Nexus 4?
from pinentryview.
5.1. I've found it has something to do with the calls to onMeasure for the pin boxes. They are being measured as too wide and setting it to HORIZONTAL_CENTER is causing the text center to be way outside the textboxes. I was able to reproduce this using genymotion nexus 4 android 5.1 build.
from pinentryview.
I don't have a Nexus 4, but I'll see if I can install and replicate it in Genymotion.
from pinentryview.
Text input does not seem to be working on my 5.1 nexus 6 either
from pinentryview.
What I've observed on some devices is that digitTextSize attribute is handled differently as the character (bullet in my case) is either too slow or too big -> so big that it is drawn out of the digit box available and not visible at all. I ended with different digitTextSize for different Android versions:
- values/dimens.xml -> digitTextSize: 30sp
- values-v18/dimens.xml -> digitTextSize: 20sp
- values-v19/dimens.xml -> digitTextSize: 12sp
Still on some device the bullet is a little big smaller or bigger but it is always placed in the center of the box and fully visible.
from pinentryview.
Not sure why but changing elevation to "0sp" instead of "0dp" seems to solve the problem
from pinentryview.
Text input also not working on Nexus 9, Android 5.1. Sounds like it's affecting tablets/big phones?
from pinentryview.
My Nexus 5 running Kitkat bricked itself today, will load it with latest Lollipop and see if I can reproduce. Failing this will try the emulator.
from pinentryview.
Not working here either on API 22 Nexus 4.
from pinentryview.
On 4.4 as well, sucks sometimes. buildSdk is 23
from pinentryview.
needs to be fixed urgently
from pinentryview.
I'm unable to commit any changes at the moment as I have limited internet and computer access, you are however welcome to submit a PR and I will try and review and publish it.
from pinentryview.
what might be wrong, if i change textsize it always gets disappear? Changed px value no luck, changed px to sp and set new value, but text is always invisible?
from pinentryview.
I am not sure if this will be helpful but I was also having the problem of the numbers not being shown.
In case you have android:layout_width="match_parent" try to change it to "wrap_content".
Now I see the numbers with that changed and seems to work. If you want to center, just use layout_gravity="center". It just works.
from pinentryview.
Thanks @RogerParis, will try that and add a new release if it seems to do the trick on a few phones.
from pinentryview.
Thank you for the good work @Philio :)
from pinentryview.
just for try to solve some issues here, try to change the code for this method
@OverRide
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Calculate the size of the view
int width = (mDigitWidth * mDigits) + (mDigitSpacing * (mDigits - 1));
setMeasuredDimension(
width + getPaddingLeft() + getPaddingRight() + (mDigitElevation * 2),
mDigitHeight + getPaddingTop() + getPaddingBottom() + (mDigitElevation * 2));
int height = MeasureSpec.makeMeasureSpec(getMeasuredHeight() / getChildCount(), MeasureSpec.EXACTLY);
// Measure children
for (int i = 0; i < getChildCount(); i ++) {
getChildAt(i).measure(width, height);
}
}
from pinentryview.
Thanks @Diego-Franco, I will see if this helps.
from pinentryview.
sure @Philio no problem, actually i create a fork from your library, this help me a lot, probably after i can share just the class because is for the company.
from pinentryview.
@Diego-Franco As far as I could tell on my test phones (running 4.4, 5.1 and 6.0) this didn't make any difference and some debugging seemed to indicate that the measurements were already being done correctly - it maybe that our versions have diverged in some way that it resulted in an improvement for you. If you have made some improvements and could contribute them back that would be great!
from pinentryview.
@Philio i just added the class to this repository https://github.com/Diego-Franco/DemoPinCodeView/blob/master/myapplication/src/main/java/com/defch/myapplication/MainActivity.java you can check any difference
from pinentryview.
Just chiming in to say that simply replacing Philio's onMeasure with Diego's has solved the issue for me. Haven't really taken the time to understand why though. Later maybe.
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Calculate the size of the view
int width = (digitWidth * digits) + (digitSpacing * (digits - 1));
setMeasuredDimension(
width + getPaddingLeft() + getPaddingRight() + (digitElevation * 2),
digitHeight + getPaddingTop() + getPaddingBottom() + (digitElevation * 2));
int height = MeasureSpec.makeMeasureSpec(getMeasuredHeight() / getChildCount(), MeasureSpec.EXACTLY);
// Measure children
for (int i = 0; i < getChildCount(); i ++) {
getChildAt(i).measure(width, height);
getChildAt(i).setSelected(true && (accentType == ACCENT_ALL ||
(accentType == ACCENT_CHARACTER && (i == digits ||
(i == digits - 1 && digits == digits)))));
}
}
from pinentryview.
@Naaate Can you tell me which device/OS version you used to reproduce it? I tried the version @Diego-Franco used and it looked like everything was the same when stepping through it with the debugger. However, I have never managed to reproduce it myself so that may be significant.
from pinentryview.
just for be clear, i'm using a HTC One (M7) with android 5.1, but when i had your code i had the same issue, after change for my piece of code is working well, i'm trying to look what can be the problem, and probably is because your put a specific size (50) in your height and your measure is not working well with this part, anyways, we need to take a look on debug @Philio
from pinentryview.
Perhaps skinned OS versions are the key (even though OP had Nexus 4). I mostly test on Nexus 5/6P and Moto X for 4.4, 5.1 and 6.0, then fill in the gaps with emulators which are all of course stock Android. I'll dig out some old ones or borrow my wife's Samsung.
from pinentryview.
from pinentryview.
With larger text size the text starts to creep out the bottom of the view, but @Diego-Franco's version didn't fix that for me (and in fact the setSelected
in onMeasure
broke the 2nd demo as the last pin box is always selected). Both issues shown in the screenshot below:
Tried a Samsung Galaxy and it was iidentical to the Nexus 5 with 4.4.4.
from pinentryview.
this is with my nexus 6p, and is working fine, i tested with my htc one m7 and is the same thing
from pinentryview.
Can you post the XML you used for that one?
from pinentryview.
After changing code above, i can give textsize and it is visible. But on some phones with different screen size text is smaller. So is there any way to change gravity of text ? I want text to be on center aways
from pinentryview.
@jemshit What text size are you using? What worked with Diego's code which didn't with the original?
I can update it if it seems to work for more people than the original did but would like to reproduce it and figure out what the difference is because when I run the debugger all the views are measured exactly the same regardless of which code is used.
from pinentryview.
Before when i've used app:digitTextSize="8sp"
, numbers were invisible. So i never could change textSize. Now it works. But of course textSize should be changed according to screen size of phone, or at least it should be centered. Because on one of my phone it is normal, fits into circle, on another phone it is smaller and aligned to top, not center.
from pinentryview.
i have this on the xml file, before i had a 15sp on the textSize and works well, for the gravity remember you can use on the DigitView you can put the gravity there.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
app:numDigits="4"
app:accentType="all"
app:digitTextSize="13sp"
app:digitTextColor="@color/brand_green"
app:pinAccentColor="@color/chime_subtext_color"
@jemshit i have this on the DigitView, you can change for "Gravitiy.CENTER"
DigitView digitView = new DigitView(getContext());
digitView.setWidth(mDigitWidth);
digitView.setHeight(mDigitHeight);
digitView.setBackgroundResource(mDigitBackground);
digitView.setTextColor(mDigitTextColor);
digitView.setTextSize(mDigitTextSize);
digitView.setGravity(Gravity.CENTER_HORIZONTAL);
addView(digitView);
from pinentryview.
@Diego-Franco Again that works either way for me and debugger gives same values :)
from pinentryview.
@Diego-Franco i have written android:gravity="center"
on xml and it didn't change gravity of numbers
from pinentryview.
Gravity is set programatically on the digits, here: https://github.com/Philio/PinEntryView/blob/master/pinentry/src/main/java/me/philio/pinentry/PinEntryView.java#L302
from pinentryview.
@Philio so we have the same values? probably we need to create the two views and check how works on different devices, sorry is late here in SF, i'll go to sleep, let me know if you need something
@jemshit not, is on the View in the class, no in the xml file, i was put my code above
from pinentryview.
I can always create a snapshot using @Diego-Franco's changes, if people are willing to test it and report back.
from pinentryview.
that's depends for the user, for me is fine, i appreciate your work with the class, i maked my own view for the company's app where i working, thanks a lot! @Philio
from pinentryview.
@Diego-Franco yep as far as I can tell both ways of measuring produce identical values and look identical on every device I've tried.
from pinentryview.
setGravity
does not make difference btw. Change your textsize to smaller and try it yourself
from pinentryview.
@jemshit How did you get the circular digits, is it just a background shape drawable?
from pinentryview.
@Philio yes
from pinentryview.
@jemshit Cool, I'll try that just to rule it out myself later when I finish work.
from pinentryview.
@jemshit do you using the measure method? actually i change for different sizes on my text and is not a problem for me, now i'm using a CENTER_HORIZONTAL, but i don't have a problem with CENTER
from pinentryview.
@Diego-Franco what was the reason for adding this to the measure method?
getChildAt(i).setSelected(true && (accentType == ACCENT_ALL ||
(accentType == ACCENT_CHARACTER && (i == digits ||
(i == digits - 1 && digits == digits)))));
It breaks the accent when it's set to single character.
from pinentryview.
actually this is just for my class on my app, forget this piece, actually is not necessary in my class anyways, i don't removed @Philio
from pinentryview.
@Philio if you're still trying to reproduce it, I've been using genymotion
Google Nexus 5 - 5.0.0 (Should be available on the free version)
with the following layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Text Hint"
android:textColor="#FFF"
/>
<diegos.on.measure.PinEntryView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:numDigits="6"
app:digitWidth="45dp"
app:digitHeight="60dp"
app:digitSpacing="2dp"
app:digitBackground="#FFFFFF"
app:digitTextSize="12sp"
app:digitTextColor="#6ec13a"
app:mask=""
app:accentType="none"
android:id="@+id/pe_register_confirm"
/>
<TextView
android:id="@+id/tv_register_resend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Kgo"
android:textColor="#FFF"
/>
</RelativeLayout>
Using your implementation makes the text entered invisible
Give that a try.
from pinentryview.
Thanks @Naaate I'll give that a try!
from pinentryview.
Reproduced the problem and confirmed that @Diego-Franco's version fixes it. I'm going to see if I can figure out exactly why but either way I'll publish a new version of the library this evening with a fix included.
from pinentryview.
Release 1.0.6 is available on Maven Central now which resolves this issue. I was also able to make an additional optimisation to the height calculation and it works well with examples I've tried and including the sample from @Naaate.
Please try it out and let me know if there are any further issues.
from pinentryview.
from pinentryview.
Related Issues (20)
- Add inputtype numberPassword HOT 2
- Query for digitSpacing
- Clearing PinEntryView
- setOnPinEnteredListener HOT 4
- not working on android 4.0.3 and 4.4
- Visible Cursor for edittext HOT 2
- Change Typeface HOT 2
- Hide keypad on click ?
- How to change mask in code. HOT 4
- accentRequiresFocus is not working
- Text size issue between platforms
- Attribute name collisions
- Specify a font family for the pin entry text
- Custom Accent Shape
- How to change number of digits programatically?
- set digitBackground to selector throws Resources NotFoundException
- setOnPinEnteredListener in version 1.0.0.6 isnt available in Maven repository HOT 1
- Add ImeOption to the library interface
- Ui issue
- No demo app on Play Store HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinentryview.