Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Commit

Permalink
Made meterView minWidth equal to it's height (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleien authored and digitalbuddha committed Oct 21, 2018
1 parent 097b98e commit 634447d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class TinyCoach
{
private FPSConfig fpsConfig;
private View meterView;
private TextView meterView;
private final WindowManager windowManager;
private int shortAnimationDuration = 200, longAnimationDuration = 700;

Expand All @@ -42,13 +42,20 @@ public TinyCoach(Application context, FPSConfig config) {
fpsConfig = config;

//create meter view
meterView = LayoutInflater.from(context).inflate(R.layout.meter_view, null);
meterView = (TextView) LayoutInflater.from(context).inflate(R.layout.meter_view, null);

//set initial fps value....might change...
((TextView) meterView).setText((int) fpsConfig.refreshRate + "");
meterView.setText((int) fpsConfig.refreshRate + "");

// grab window manager and add view to the window
windowManager = (WindowManager) meterView.getContext().getSystemService(Service.WINDOW_SERVICE);

int minWidth = meterView.getLineHeight()
+ meterView.getTotalPaddingTop()
+ meterView.getTotalPaddingBottom()
+ (int) meterView.getPaint().getFontMetrics().bottom;
meterView.setMinWidth(minWidth);

addViewToWindow(meterView);
}

Expand Down Expand Up @@ -107,7 +114,7 @@ public void showData(FPSConfig fpsConfig, List<Long> dataSet) {
meterView.setBackgroundResource(R.drawable.fpsmeterring_good);
}

((TextView) meterView).setText(answer.getValue() + "");
meterView.setText(answer.getValue() + "");
}

public void destroy() {
Expand Down
1 change: 1 addition & 0 deletions tinydancer/src/main/res/layout/meter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/fpsmeterring_good"
android:gravity="center"
android:padding="10dp"
android:textColor="@android:color/black"
android:textSize="19sp"
Expand Down

0 comments on commit 634447d

Please sign in to comment.