2014-10-21 3 views
10

API에서 EditText 패딩이 작동하지 않습니다. 21 빈 EditText로만 프로젝트를 시도하지만 여전히 작동하지 않습니다.API에서 EditText 패딩 21

패딩은 프로그래밍 방식으로 작동하지만 내 작업 프로젝트에서는 다양한 패딩을 가진 많은 EditText를 사용하고 프로그래밍 방식으로 패딩을 프로그래밍 방식으로 설정했습니다.

API 레벨 19에서 xml 패딩이 잘 작동합니다.

해결책이 있습니까?

이 내 글고의 XML 코드 : 결과에서

<EditText 
    android:id="@+id/et_text" 
    android:text="Text" 
    android:paddingLeft="20dp" 
    android:paddingStart="20dp" 
    android:paddingRight="20dp" 
    android:paddingEnd="20dp" 
    android:layout_marginLeft="30dp" 
    android:layout_marginRight="30dp" 
    android:layout_width="match_parent" 
    android:layout_height="45dp"/> 

, 내가있어 : enter image description here

내가 기대 :

enter image description here

+1

여기에서 같은 문제가 발생합니다. 내 편집 텍스트는 API 21로 업데이트 한 후에 패딩을 적용하지 않습니다. –

답변

8

이것은 Android 버그입니다. 앞으로는 수정 될 것입니다.

Bug report on google code.

+1

버그가 12 월 18 일에 폐쇄되었으므로 잘하면 다음 릴리스에서 릴리스 될 것입니다. – IlyaEremin

+0

이것은 android : paddingStart를 사용하면 해결 될 것이므로 수정되지 않는 것처럼 보입니다. –

1

봅니다 사용하여 프로그래밍 방식으로 패딩을 제공하기 위해 방법 setLayoutParams() 내가 희망이 작동합니다 참조 : Example

+1

내 프로젝트에서 다른 패딩과 함께 많은 edittext를 사용하고 프로그래밍 방식으로 패딩을 설정합니다.이 작업을 해결할 엄두는 방법이 아닙니다. – user3134124

+2

패딩을 프로그래밍 방식으로 설정했는지 확인하지만 @ user3134124에 동의합니다. – tokudu

-1

안드로이드의 standart 글고 사용하여 스타일을 해결 : 정말

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
    <item name="android:editTextStyle">@android:style/Widget.EditText</item> 
</style> 
0

아니 문제를 해결하는 가장 좋은 방법,하지만 나를 위해 작동합니다 : 당신이 안드로이드를 설정할 수 있습니다 : layout_height를 어떤 고정 값 및 속성을 설정 로이드 중력센터 또는center_vertical

<EditText 
     ... 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:gravity="center" 
     .../> 
4

패딩이있는 사용자 정의 편집 문구를 만들어 xml에서 사용하여 해결했습니다. 어쨌든 및 수정 해당 장치에이 버그를해야한다으로

0

그냥, android:paddingStartandroid:paddingLeft 교체

public class MyEditTextView extends EditText{ 

public MyEditTextView(Context context) { 
    super(context); 
    init(); 
} 

public MyEditTextView(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    init(); 
} 

public MyEditTextView(Context context, AttributeSet attrs, int defStyleAttr) { 
    super(context, attrs, defStyleAttr); 
    init(); 
} 

private void init(){ 
    int paddingLeftRight = (int) getResources().getDimension(R.dimen.edittext_padding); 
    int topPadding = this.getPaddingTop(); 
    int bottomPadding = this.getPaddingBottom(); 
    setPadding(paddingLeftRight, topPadding, paddingLeftRight, bottomPadding); 
} 

}.