2016-09-11 9 views
1

DatePickerDialog 오른쪽에 여분의 공간이 표시됩니다 (Android M & N 빌드에서만). L 기반 빌드에서는 관찰되지 않습니다.DatePickerDialog에서 추가 공간 공간을 제거하는 방법 (Android M & N에 표시됨)?

사람이 문제를 직면하고 다음은 스크린 샷입니까?

DatePickerFragment의 구현 :

public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { 

    public static DatePickerFragment newInstance(int day, int month, int year) 
    { 
     DatePickerFragment frag = new DatePickerFragment(); 
     Bundle args = new Bundle(); 
     args.putInt("day", day); 
     args.putInt("month", month); 
     args.putInt("year", year); 
     frag.setArguments(args); 
     return frag; 
    } 

    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) 
    { 
     int year = getArguments().getInt("year"); 
     int month = getArguments().getInt("month"); 
     int day = getArguments().getInt("day"); 
     DatePickerDialog datePickerDialog =new DatePickerDialog(getActivity(), this, year, month, day); 
     datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000); 
     return datePickerDialog; 
    } 

    @Override 
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) 
    { 
     try 
     { 
      DatePickerDialogListener listener = (DatePickerDialogListener)getActivity(); 
      listener.onFinishDatePickDialog(year, monthOfYear + 1, dayOfMonth); 
     } 
     catch (Exception ex) 
     { 
      ex.printStackTrace(); 
     } 
    } 

    // 1. Defines the listener interface with a method passing back data result. 
    public interface DatePickerDialogListener { 
     void onFinishDatePickDialog(int year, int monthOfYear, int dayOfMonth); 
    } 

} 

을 그리고 여기 안드로이드에 대한 구성 요소가 스타일 시트의 : datePickerDialogTheme

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="android:windowContentTransitions">true</item> 
     <item name="colorControlNormal">@color/colorAccent</item> 
     <item name="colorControlActivated">@color/colorAccent</item> 
     <item name="colorControlHighlight">@color/colorAccent</item> 
     <item name="textColorError">@android:color/holo_red_dark</item> 
     <item name="android:timePickerDialogTheme">@style/AlertDialogCustom</item> 
     <item name="android:datePickerDialogTheme">@style/AlertDialogCustom</item> 
     <item name="android:alertDialogTheme">@style/AlertDialogCustom</item> 
    </style> 

    <style name="AlertDialogCustom" parent="android:Theme.Material.Light.Dialog.Alert"> 
     <item name="android:colorPrimary">@color/colorPrimary</item> 
     <item name="android:colorAccent">@color/colorAccent</item> 
    </style> 

참고 : 문제가되지는 색상을 수정하기 위해 스타일을 사용하지 않으면 보입니다.

+0

나를 도와 같이한다 무엇 녹색 유지 https://stackoverflow.com/a/41456791/2452029 – Lanitka

답변

1

수정 사항을 발견했습니다. 제 스타일에 문제가있었습니다. 부모를 테마로 변경했습니다 .AppCompat.Light.Dialog.Alert android : Theme.Material.Light.Dialog.Alert 대신 대신에 업데이트했습니다.

또한 안드로이드 : colorAccent는 colorAccent로 변경해야합니다 그렇지 않으면 달력 선택기 색상은

여기

최종 스타일은 다음과 같이 대화 상자를 만들기

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert"> 
    <item name="colorAccent">@color/colorAccent</item> 
</style>