2014-03-28 4 views
2

두 개의 editText가있는 기울임 꼴 글꼴이있는 간단한 양식을 가지고 있지만 첫 번째 위치에 놓으면 왼쪽에 일부 문자 (p 및 j)가 "cutted"됩니다. drawablePadding으로 해결하려고했지만 작동하지 않습니다. 필자의 경우 첫 번째 글자 앞에 공백을 삽입하는 것은 해결책이 아닙니다. 적어도 두 번째 형식 필드는 암호이므로 공백 문자로 인해 점이 자동으로 사용자에게 표시됩니다. 활동에기울임 꼴 EditText는 첫 글자를 자름

<EditText 
     android:id="@+id/edit_txt_login" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/rectangle_white" 
     android:drawableLeft="@drawable/ic_mail" 
     android:drawablePadding="10dp" 
     android:ems="10" 
     android:hint="@string/login_email_placeholder" 
     android:imeOptions="actionNext" 
     android:inputType="textEmailAddress" 
     android:padding="10dp" 
     android:textColor="@color/black" 
     android:textCursorDrawable="@null" 
     android:textColorHint="@color/color_form_login_text" 
     android:textSize="17sp" > 

:

Typeface edit_text_font = Typeface.createFromAsset(getActivity().getAssets(), 
      "fonts/helvetica-bold-italic.ttf"); 

    //Set Fonts 
    mEditTxtLogin.setTypeface(edit_text_font); 

버그 이미지 :

screenshot of the bug

솔루션이 무엇 인 글고 치기는 다음과 같은 코드가?

+1

당신이 –

+0

@nomada을 제거하려고 작동하지 마십시오 –

+0

아래에있는 내 대답은 EMS를 제거 볼 수 있습니다 EMS – nomada

답변

1

이 감소 제공하는 시도는 솔루션입니다. 사용자 정의 글꼴로 사용자 정의 EditText를 만들었습니다.

package com.example.customcontrols; 

import android.content.Context; 
import android.graphics.Typeface; 
import android.util.AttributeSet; 
import android.widget.EditText; 

public class MyEditTextItalic extends EditText { 
    /* 
    * Caches typefaces based on their file path and name, so that they don't 
    * have to be created every time when they are referenced. 
    */ 
    private static Typeface mTypeface; 

    public MyEditTextItalic(Context context) { 
     super(context); 
     setTypeface(context); 
    } 

    public MyEditTextItalic(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
     setTypeface(context); 
    } 

    public MyEditTextItalic(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     setTypeface(context); 
    } 

    // intercept Typeface change and set it with our custom font 
    public void setTypeface(Context context) { 
     if (mTypeface == null) { 
      mTypeface = Typeface.createFromAsset(context.getAssets(), 
        "fonts/HelveticaNeue-Bold.otf"); 
     } 

     super.setTypeface(mTypeface,Typeface.ITALIC); 

    } 
} 

이 폰트를 사용 super.setTypeface (mTypeface, Typeface.ITALIC)을 설정할 때 사용 기울임에 대한 제대로 표시되지 않기 때문에 서체 기울임을 만들 수 없습니다 매우 중요하다; 이 나를 위해 일했다 .XML

<com.example.customcontrols.MyEditTextItalic 
      android:id="@+id/edit_txt_password" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="15dp" 
      android:background="@drawable/rectangle_white" 
      android:drawableLeft="@drawable/ic_key" 
      android:drawablePadding="10dp" 
      android:ems="10" 
      android:hint="@string/login_password_placeholder" 
      android:imeOptions="actionDone" 
      android:inputType="textPassword" 
      android:padding="10dp" 
      android:textColor="@color/black" 
      android:textCursorDrawable="@null" 
      android:textStyle="bold|italic" 
      android:textColorHint="@color/color_form_login_text" 
      android:textSize="17sp" /> 
-1

padding왼쪽에서 사용할 수 있습니다. 당신의 layout.xml에 다음 줄을 추가하십시오 :

android:paddingLeft="20dp" //you can set it what you need 
+0

작동하지 않습니다 :-( – nomada

+0

50dp 이상 시도해주세요. 영향을받은 항목은 무엇입니까? 다시 시도해보고 화면을 보낼 수 있습니까? –

+0

with android : paddingLeft = "6 0 "첫 번째 textview 결과 [이미지 링크] (https://googledrive.com/host/0B9M1_CSCWMt-anZCdlZIeUxMdDQ/Captura%20de%20pantalla%202014-03-31%20a%20la%28s%29%2011.26 .53.png). – nomada

0

를 추가해보십시오 패딩 왼쪽. 이 시도 :

<EditText 
     android:id="@+id/edit_txt_login" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/rectangle_white" 
     android:drawableLeft="@drawable/ic_mail" 
     android:drawablePadding="10dp" 
     android:ems="10" 
     android:hint="@string/login_email_placeholder" 
     android:imeOptions="actionNext" 
     android:inputType="textEmailAddress" 
     android:padding="10dp" 
     android:paddingLeft="45dp" 
     android:textColor="@color/black" 
     android:textCursorDrawable="@null" 
     android:textColorHint="@color/color_form_login_text" 
     android:textSize="17sp" > 
0

android:paddingLeft 이상의 10dp 또는이 android:drawablePadding 4 또는 5dp

+0

이 솔루션은 작동하지 않습니다! – nomada

0

에서

은 XML 레이아웃으로 사용자 정의 을 설정

android:width="130dp" //Define a value larger than your text.