1

왼쪽, 공간, 가운데 3 개, 공백 1 개, 키 3 개가있는 사용자 정의 키패드 레이아웃을 만들려고합니다. 더하기 기호로 표시, 키보드의 행과 같아야합니다android에서 KeyboardView 적용

+ + + = + + + = + 더하기 기호가 열쇠와 =이 공간을 나타냅니다

. 내 XML 코드는 다음과 같습니다 안드로이드 4.4에

<?xml version="1.0" encoding="utf-8"?> 
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android" 
android:keyWidth="12.50%p" 
android:keyHeight="8.9%p"> 


<Row> 
    <Key android:codes="1"  android:keyLabel="sin"       android:isRepeatable="true" android:keyEdgeFlags="left" /> 
    <Key android:codes="2"  android:keyLabel="cos"      android:isRepeatable="true" /> 
    <Key android:codes="3"  android:keyLabel="tan"      android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="-1"  android:keyLabel="DRAW"      android:isRepeatable="true" android:keyWidth="25%p"  /> 
    <Key android:codes="22"  android:keyLabel="x\u207F"     android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="-2"  android:keyIcon="@drawable/delete_symbol" android:isRepeatable="true" android:keyEdgeFlags="right"/> 
</Row> 
<Row> 
    <Key android:codes="4"  android:keyLabel="asin"  android:isRepeatable="true"  android:keyEdgeFlags="left" /> 
    <Key android:codes="5"  android:keyLabel="acos"  android:isRepeatable="true" /> 
    <Key android:codes="6"  android:keyLabel="atan"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="36"  android:keyLabel="sinh"  android:isRepeatable="true" /> 
    <Key android:codes="37"  android:keyLabel="cosh"  android:isRepeatable="true" /> 
    <Key android:codes="38"  android:keyLabel="tanh"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="21"  android:keyLabel="\u00F7" android:isRepeatable="true" android:keyEdgeFlags="right" /> 
</Row> 
<Row> 
    <Key android:codes="42"  android:keyLabel="asinh" android:isRepeatable="true"  android:keyEdgeFlags="left" /> 
    <Key android:codes="43"  android:keyLabel="acosh"  android:isRepeatable="true" /> 
    <Key android:codes="44"  android:keyLabel="atanh"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="33"  android:keyLabel="7"  android:isRepeatable="true"  /> 
    <Key android:codes="34"  android:keyLabel="8"  android:isRepeatable="true" /> 
    <Key android:codes="35"  android:keyLabel="9"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p"/> 
    <Key android:codes="20"  android:keyLabel="\u00D7" android:isRepeatable="true" android:keyEdgeFlags="right" /> 
</Row> 

<Row> 
    <Key android:codes="10"  android:keyLabel="\u221a" android:keyEdgeFlags="left"  android:isRepeatable="true" /> 
    <Key android:codes="11"  android:keyLabel="e^("  android:isRepeatable="true" /> 
    <Key android:codes="12"  android:keyLabel="ln("  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="30"  android:keyLabel="4"  android:isRepeatable="true"  /> 
    <Key android:codes="31"  android:keyLabel="5"  android:isRepeatable="true" /> 
    <Key android:codes="32"  android:keyLabel="6"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="19"  android:keyLabel="\u2212"  android:isRepeatable="true"  android:keyEdgeFlags="right" /> 
</Row> 

<Row> 
    <Key android:codes="40"  android:keyLabel="log"  android:isRepeatable="true"  android:keyEdgeFlags="left" /> 
    <Key android:codes="41"  android:keyLabel="abs" android:isRepeatable="true" /> 
    <Key android:codes="13"  android:keyIcon="@drawable/italic_x"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p"/> 
    <Key android:codes="27"  android:keyLabel="1"  android:isRepeatable="true"  /> 
    <Key android:codes="28"  android:keyLabel="2"  android:isRepeatable="true" /> 
    <Key android:codes="29"  android:keyLabel="3"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p"/> 
    <Key android:codes="18"  android:keyLabel="+"  android:isRepeatable="true"  android:keyEdgeFlags="right" /> 
</Row> 

<Row> 
    <Key android:codes="-3"  android:keyIcon="@drawable/keyboard_done"  android:isRepeatable="true"  android:keyWidth="25%p"   android:keyEdgeFlags="left" /> 
    <Key android:codes="19"  android:keyLabel="(-)"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="16"  android:keyLabel="("  android:isRepeatable="true"  /> 
    <Key android:codes="26"  android:keyLabel="0"  android:isRepeatable="true" /> 
    <Key android:codes="17"  android:keyLabel=")"  android:isRepeatable="true" 
     android:horizontalGap="6.25%p" /> 
    <Key android:codes="23"  android:keyLabel="."  android:isRepeatable="true"  android:keyEdgeFlags="right" /> 
</Row> 

; 특히 삼성 갤럭시 s4와 s5, 사용자 정의 키패드가 멋지게 나타납니다. 삼성 갤럭시 S3와 5인치보다 작은 화면 크기와 장치의 나머지 부분에 키패드 왜곡과 같습니다

++ = ++++++

사용자 정의에 대한 내 XML 코드 뒤에 추론을 - 행에 7 개의 키가 있습니다. - 각 키는 화면 너비의 12.5 %를 차지합니다 (7 키의 경우 총 87.5 %). - 각 2 개의 기본 공백 (= 내 로그인 그림)은 화면 너비의 6.25 %를 차지합니다. - 위는 총 화면 너비를 100 %로 만듭니다.

제 생각에 따르면 xml 파일은 모든 장치에서 작동해야합니다. 그러나 이것은 일어나지 않습니다.

Google에서 솔루션을 검색하면서 키보드보기에 버그가 있음을 알게되었습니다.

NOTE When we add a horizontalGap in pixels, this interferes with keyWidth in percentages adding up to 100% 
NOTE When we have a horizontalGap (on Keyboard level) of 0, this make the horizontalGap (on Key level) to move from after the key to before the key... (I consider this a bug) 

사람이

답변

1

예,이 안드로이드의 버그이지만, 다행히 해결 방법은 도움을 주시기 바랍니다 수 : 버그는 다음과 같이 설명했다.

해결책은 공백이 필요한 키 사이에 horizontalGap> 0 및 width = 0 인 빈 키를 추가하는 것입니다. 이 빈 키는 horizontalGap이있는 유일한 키입니다. 다른 모든 키에는이 속성이 없어야합니다.

<Row> 
    <Key android:codes="1" android:keyLabel="First key" android:keyEdgeFlags="left" /> 
    <Key android:codes="-999" android:keyLabel="" android:keyWidth="0%p" android:horizontalGap="2.0%p" /> 
    <Key android:codes="2" android:keyLabel="Second key" /> 
    <Key android:codes="-999" android:keyLabel="" android:keyWidth="0%p" android:horizontalGap="2.0%p" /> 
    <Key android:codes="3" android:keyLabel="Third key" android:keyEdgeFlags="right"/> 
</Row> 
: 여기

그들 사이에 공간이 세 보이는 키의 내 자신의 예입니다