Currently the bottom row is clipped on WVGA-800.
Changes were made to fix the emergency dialer
that needed to be applied to the contact dialer.
Now, the contact dialer uses the same ButtonGridLayout
class which aligns the button at the bottom of the view.
This way we can control the spacing between the last row and
the 'torpedo' accurately.
The rest of the white space is distributed amongst the element
using layout_weight="1".
Tested on VGA, WVGA-854, WVGA-800
Bug:
2198341
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
>
<ImageButton android:id="@+id/one"
android:layout_width="88dp"
<EditText android:id="@+id/digits"
android:layout_width="fill_parent"
android:layout_height="67dip"
- android:layout_marginBottom="6dip"
android:gravity="center"
android:maxLines="1"
android:scrollHorizontally="true"
android:focusableInTouchMode="true"
android:editable="true"
android:cursorVisible="false"
+ android:layout_weight="0"
/>
<!-- Keypad section -->
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="6dip"
+ android:layout_weight="1"
android:orientation="horizontal">
<!-- Onscreen "Voicemail" button.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
>
<ImageButton android:id="@+id/one"
android:layout_width="88dp"
<EditText android:id="@+id/digits"
android:layout_width="fill_parent"
android:layout_height="74dip"
- android:layout_marginBottom="20dip"
android:gravity="center"
android:maxLines="1"
android:scrollHorizontally="true"
android:focusableInTouchMode="true"
android:editable="true"
android:cursorVisible="false"
+ android:layout_weight="0"
/>
<!-- Keypad section -->
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginTop="24dip"
+ android:layout_marginTop="6dip"
+ android:layout_weight="1"
android:orientation="horizontal">
- <!-- Onscreen "Voicemail" button -->
+ <!-- Onscreen "Voicemail" button.
+ The width is 75 (from the mocks) + 12 of padding from the
+ 9patch, total is 87.
+ -->
<ImageButton android:id="@+id/voicemailButton"
android:layout_width="87dip"
android:layout_height="58dip"
android:background="@drawable/btn_dial_action"
android:src="@drawable/ic_dial_action_call" />
- <!-- Onscreen "Backspace/Delete" button -->
+ <!-- Onscreen "Backspace/Delete" button
+ The width is 75 (from the mocks) + 12 of padding from the
+ 9patch, total is 87.
+ -->
<ImageButton android:id="@+id/deleteButton"
android:layout_width="87dip"
android:layout_height="58dip"
* - vertical = top + bottom padding.
*
* This class assumes that all the buttons have the same size.
+ * The buttons will be bottom aligned in their view on layout.
*
* Invocation: onMeasure is called first by the framework to know our
* size. Then onLayout is invoked to layout the buttons.
private int mWidthInc;
private int mHeightInc;
+ // Height of the dialpad. Used to align it at the bottom of the
+ // view.
+ private int mHeight;
+
public ButtonGridLayout(Context context) {
super(context);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int i = 0;
- int y = mPaddingTop;
+ // The last row is bottom aligned.
+ int y = (b - t) - mHeight + mPaddingTop;
for (int row = 0; row < ROWS; row++) {
int x = mPaddingLeft;
for (int col = 0; col < COLUMNS; col++) {
mButtonHeight = child.getMeasuredHeight();
mWidthInc = mButtonWidth + mPaddingLeft + mPaddingRight;
mHeightInc = mButtonHeight + mPaddingTop + mPaddingBottom;
+ mHeight = ROWS * mHeightInc;
final int width = resolveSize(COLUMNS * mWidthInc, widthMeasureSpec);
- final int height = resolveSize(ROWS * mHeightInc, heightMeasureSpec);
+ final int height = resolveSize(mHeight, heightMeasureSpec);
setMeasuredDimension(width, height);
}
-
}