Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Functionality of setTextColor via XML. #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cursorVisible="false"
app:forceKeyboard="true"
app:forceKeyboard="true"
app:textColor="#ff0000"
app:hint=""
app:inputType="number"
app:password="false"
Expand Down
19 changes: 11 additions & 8 deletions pinview/src/main/java/com/goodiebag/pinview/Pinview.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ public class Pinview extends LinearLayout implements TextWatcher, View.OnFocusCh
/**
* Attributes
*/
private int mPinLength = 4;
private List<EditText> editTextList = new ArrayList<>();
private int mPinWidth = 50;
private int mTextSize = 12;
private int mPinHeight = 50;
private int mSplitWidth = 20;
private boolean mCursorVisible = false;
private boolean mDelPressed = false;
private int mPinLength = 4;
private List<EditText> editTextList = new ArrayList<>();
private int mPinWidth = 50;
private int mTextSize = 12;
private int mTextColor = getResources().getColor(android.R.color.black);
private int mPinHeight = 50;
private int mSplitWidth = 20;
private boolean mCursorVisible = false;
private boolean mDelPressed = false;
@DrawableRes
private int mPinBackground = R.drawable.sample_background;
private boolean mPassword = false;
Expand Down Expand Up @@ -184,6 +185,7 @@ private void createEditTexts() {
for (int i = 0; i < mPinLength; i++) {
editText = new EditText(getContext());
editText.setTextSize(mTextSize);
editText.setTextColor(mTextColor);
editTextList.add(i, editText);
this.addView(editText);
generateOneEditText(editText, "" + i);
Expand All @@ -207,6 +209,7 @@ private void initAttributes(Context context, AttributeSet attrs, int defStyleAtt
mPinWidth = (int) array.getDimension(R.styleable.Pinview_pinWidth, mPinWidth);
mSplitWidth = (int) array.getDimension(R.styleable.Pinview_splitWidth, mSplitWidth);
mTextSize = (int) array.getDimension(R.styleable.Pinview_textSize, mTextSize);
mTextColor = array.getColor(R.styleable.Pinview_textColor, mTextColor);
mCursorVisible = array.getBoolean(R.styleable.Pinview_cursorVisible, mCursorVisible);
mPassword = array.getBoolean(R.styleable.Pinview_password, mPassword);
mForceKeyboard = array.getBoolean(R.styleable.Pinview_forceKeyboard, mForceKeyboard);
Expand Down
1 change: 1 addition & 0 deletions pinview/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<attr name="hint" format="string"/>
<attr name="inputType"/>
<attr name="textSize" format="dimension"/>
<attr name="textColor" format="color"/>
</declare-styleable>
<attr name="inputType" format="enum">
<enum name="text" value="0"/>
Expand Down