Skip to content

Commit

Permalink
Programmatically set floating label and bottom texts's text size.
Browse files Browse the repository at this point in the history
  • Loading branch information
rengwuxian committed Jan 11, 2015
1 parent 3639260 commit f9a5636
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public class MaterialAutoCompleteTextView extends AutoCompleteTextView {
/**
* the floating label's text size.
*/
private final int floatingLabelTextSize;
private int floatingLabelTextSize;

/**
* the bottom texts' size.
*/
private final int bottomTextSize;
private int bottomTextSize;

/**
* the spacing between the main text and the floating label.
Expand Down Expand Up @@ -533,6 +533,24 @@ public void setFloatingLabelText(@Nullable CharSequence floatingLabelText) {
postInvalidate();
}

public int getFloatingLabelTextSize() {
return floatingLabelTextSize;
}

public void setFloatingLabelTextSize(int size) {
floatingLabelTextSize = size;
initPadding();
}

public int getBottomTextSize() {
return bottomTextSize;
}

public void setBottomTextSize(int size) {
bottomTextSize = size;
initPadding();
}

private int getPixel(int dp) {
return Density.dp2px(getContext(), dp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public class MaterialEditText extends EditText {
/**
* the floating label's text size.
*/
private final int floatingLabelTextSize;
private int floatingLabelTextSize;

/**
* the bottom texts' size.
*/
private final int bottomTextSize;
private int bottomTextSize;

/**
* the spacing between the main text and the floating label.
Expand Down Expand Up @@ -533,6 +533,24 @@ public void setFloatingLabelText(@Nullable CharSequence floatingLabelText) {
postInvalidate();
}

public int getFloatingLabelTextSize() {
return floatingLabelTextSize;
}

public void setFloatingLabelTextSize(int size) {
floatingLabelTextSize = size;
initPadding();
}

public int getBottomTextSize() {
return bottomTextSize;
}

public void setBottomTextSize(int size) {
bottomTextSize = size;
initPadding();
}

private int getPixel(int dp) {
return Density.dp2px(getContext(), dp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public class MaterialMultiAutoCompleteTextView extends MultiAutoCompleteTextView
/**
* the floating label's text size.
*/
private final int floatingLabelTextSize;
private int floatingLabelTextSize;

/**
* the bottom texts' size.
*/
private final int bottomTextSize;
private int bottomTextSize;

/**
* the spacing between the main text and the floating label.
Expand Down Expand Up @@ -530,6 +530,24 @@ public void setFloatingLabelText(@Nullable CharSequence floatingLabelText) {
postInvalidate();
}

public int getFloatingLabelTextSize() {
return floatingLabelTextSize;
}

public void setFloatingLabelTextSize(int size) {
floatingLabelTextSize = size;
initPadding();
}

public int getBottomTextSize() {
return bottomTextSize;
}

public void setBottomTextSize(int size) {
bottomTextSize = size;
initPadding();
}

private int getPixel(int dp) {
return Density.dp2px(getContext(), dp);
}
Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.rengwuxian.materialedittext:library:1.8.0'
// compile project(':library')
// compile 'com.rengwuxian.materialedittext:library:1.8.0'
compile project(':library')
}
2 changes: 1 addition & 1 deletion sample/sample.iml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="library-1.8.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>

0 comments on commit f9a5636

Please sign in to comment.