Skip to content

Commit

Permalink
text size
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgi-abashidze committed Dec 15, 2020
1 parent b0ef0b8 commit 7ae2899
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:layout_height="50dp"
app:PBC_Text="@{defaultButtonText}"
app:PBC_Radius="10dp"
app:PBC_TextSize="16"
app:PBC_TextColor="#ffffff"
/>
<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void setPBCText(String PBCText) {
private static final int[] PBC_TEXT_COLOR = {R.attr.PBC_TextColor};
private static final int[] PBC_TEXT_STYLE = {R.attr.PBC_TextStyle};
private static final int[] PBC_RADIUS = {R.attr.PBC_Radius};
private static final int[] PBC_TEXT_SIZE = {R.attr.PBC_TextSize};

public Default(Context context) {

Expand Down Expand Up @@ -137,10 +138,8 @@ public Default(Context context, @Nullable AttributeSet attrs) {

int paddingNum = displayMetrics.xdpi <= 160 ? 4 : displayMetrics.xdpi > 160 && displayMetrics.xdpi <= 213 ? 3 : 2;

progressBar.setPadding(0,dp / paddingNum,0,dp / paddingNum);
//textView.setPadding(dp / 2,dp / 2,dp / 2,dp / 2);

PBCTextSize = (dp / 2) - (dp / 6);
progressBar.setPadding(0,dp / 2,0,dp / 2);
textView.setPadding(dp / 2,dp / 2,dp / 2,dp / 2);

}finally {
ta0.recycle();
Expand All @@ -149,12 +148,13 @@ public Default(Context context, @Nullable AttributeSet attrs) {
//get custom attributes
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Default, 0, 0);
try {

DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
PBCRadius = ta.getDimension(R.styleable.Default_PBC_Radius,0);

PBCText = ta.getString(R.styleable.Default_PBC_Text);
PBCTextColor = ta.getString(R.styleable.Default_PBC_TextColor);
PBCTextStyle = ta.getInt(R.styleable.Default_PBC_TextStyle,0);
PBCTextSize = ta.getInt(R.styleable.Default_PBC_TextSize,5);

textView.setText(PBCText);
textView.setTextSize(PBCTextSize);
Expand Down Expand Up @@ -242,10 +242,11 @@ public void Dispose(){
@Override
protected int[] onCreateDrawableState(int extraSpace) {

final int[] drawableState = super.onCreateDrawableState(extraSpace + 4);
final int[] drawableState = super.onCreateDrawableState(extraSpace + 5);
mergeDrawableStates(drawableState, PBC_TEXT);
mergeDrawableStates(drawableState, PBC_TEXT_COLOR);
mergeDrawableStates(drawableState, PBC_TEXT_STYLE);
mergeDrawableStates(drawableState, PBC_TEXT_SIZE);
mergeDrawableStates(drawableState, PBC_RADIUS);
return drawableState;
}
Expand Down
3 changes: 3 additions & 0 deletions progress_button_card/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<attr name="PBC_Radius" format="dimension" />
<attr name="PBC_StartColor" format="string" />
<attr name="PBC_EndColor" format="string" />
<attr name="PBC_TextSize" format="integer" />

<attr name="PBC_Gradient_Orientation" format="enum">
<enum name="top_bottom" value="0"/>
Expand All @@ -23,6 +24,7 @@
<attr name="PBC_Text"/>
<attr name="PBC_TextColor" />
<attr name="PBC_TextStyle" />
<attr name="PBC_TextSize" />
<attr name="PBC_Radius" />
</declare-styleable>

Expand All @@ -32,6 +34,7 @@
<attr name="PBC_TextStyle" />
<attr name="PBC_Radius" />
<attr name="PBC_StartColor" />
<attr name="PBC_TextSize" />
<attr name="PBC_EndColor" />
<attr name="PBC_Gradient_Orientation" />
</declare-styleable>
Expand Down

0 comments on commit 7ae2899

Please sign in to comment.