This commit is contained in:
juloo 2015-08-02 23:36:22 +02:00
parent 6737bda402
commit 3d3aa4bc98
2 changed files with 3 additions and 7 deletions

View File

@ -1,8 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android" <juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard2"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bg" android:background="@color/bg"
/> />

View File

@ -39,14 +39,12 @@ public class Keyboard2View extends View
public Keyboard2View(Context context, AttributeSet attrs) public Keyboard2View(Context context, AttributeSet attrs)
{ {
super(context, attrs); super(context, attrs);
DisplayMetrics dm = context.getResources().getDisplayMetrics();
_verticalMargin = getResources().getDimension(R.dimen.vertical_margin); _verticalMargin = getResources().getDimension(R.dimen.vertical_margin);
_horizontalMargin = getResources().getDimension(R.dimen.horizontal_margin); _horizontalMargin = getResources().getDimension(R.dimen.horizontal_margin);
_keyHeight = getResources().getDimension(R.dimen.key_height); _keyHeight = getResources().getDimension(R.dimen.key_height);
_keyPadding = getResources().getDimension(R.dimen.key_padding); _keyPadding = getResources().getDimension(R.dimen.key_padding);
_keyBgPadding = getResources().getDimension(R.dimen.key_bg_padding); _keyBgPadding = getResources().getDimension(R.dimen.key_bg_padding);
_keyRound = getResources().getDimension(R.dimen.key_round); _keyRound = getResources().getDimension(R.dimen.key_round);
_keyWidth = (dm.widthPixels - (_horizontalMargin * 2)) / KEY_PER_ROW;
_keyBgPaint.setColor(getResources().getColor(R.color.key_bg)); _keyBgPaint.setColor(getResources().getColor(R.color.key_bg));
_keyDownBgPaint.setColor(getResources().getColor(R.color.key_down_bg)); _keyDownBgPaint.setColor(getResources().getColor(R.color.key_down_bg));
_keyLabelPaint.setColor(getResources().getColor(R.color.key_label)); _keyLabelPaint.setColor(getResources().getColor(R.color.key_label));
@ -203,6 +201,7 @@ public class Keyboard2View extends View
@Override @Override
public void onMeasure(int wSpec, int hSpec) public void onMeasure(int wSpec, int hSpec)
{ {
DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
int height; int height;
if (_keyboard.getRows() == null) if (_keyboard.getRows() == null)
@ -210,7 +209,8 @@ public class Keyboard2View extends View
else else
height = (int)(_keyHeight * ((float)_keyboard.getRows().size()) height = (int)(_keyHeight * ((float)_keyboard.getRows().size())
+ (_verticalMargin * 2)); + (_verticalMargin * 2));
setMeasuredDimension(MeasureSpec.getSize(wSpec), height); setMeasuredDimension(dm.widthPixels, height);
_keyWidth = (getWidth() - (_horizontalMargin * 2)) / KEY_PER_ROW;
} }
@Override @Override