2016-07-26 3 views
0

DatePicker가 캘린더보기로 표시되면이 캘린더보기 하단에 텍스트로 추가 레이블을 붙일 수 있습니까 (그림 참조)? 나는 원래 안드로이드 DatePicker를 사용자 정의 할 가능성이 있는지 찾고 있었지만, 적절한 방법을 찾을 수 없었습니다.Android DatePicker 레이아웃 사용자 정의

datepicker

답변

3

당신은 here에서 소스 코드를 얻을 수 있습니다.

원하는대로 레이아웃을 사용자 정의하려면 layout-land/mdtp_date_picker_dialog.xmllayout-sw600dp-land/mdtp_date_picker_dialog.xml 필드를 수정해야합니다. 저는 여기에 스크린 샷으로 두 TextViews을 추가 한 : 당신이 원하는대로 dimens 관련

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/mdtp_background_color" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="450dp" 
     android:gravity="center" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:orientation="vertical"> 

      <include layout="@layout/mdtp_date_picker_header_view" /> 

      <include layout="@layout/mdtp_date_picker_selected_date" /> 

      <include layout="@layout/mdtp_date_picker_footer_view" /> 

      <TextView 
       android:id="@+id/added_text" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:padding="8dp" 
       android:text="Some Text" /> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:orientation="vertical"> 

      <include layout="@layout/mdtp_date_picker_view_animator" /> 

      <TextView 
       android:id="@+id/added_text2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Some text" /> 
     </LinearLayout> 

    </LinearLayout> 

    <include layout="@layout/mdtp_done_button" /> 
</LinearLayout> 

변경이 TextViews를 찾습니다.

+0

아직 작업하고 있지만 필요한 것 같습니다. 고맙습니다. – etilia

+0

향후 안드로이드 버전에서 깨지지 않도록 보장되어 있습니까? Android에서 공식 API를 보지 못했습니다. – Dibzmania

0

나는 비슷한 문제에 직면했다. this 라이브러리를 사용하는 것이 좋습니다.

원하는 방식으로이 라이브러리를 사용자 정의 할 수 있습니다. 레이아웃 파일을 편집하고 원하는 특정 레이아웃을 확장하면됩니다. 또한 레이아웃 파일에 쉽게 레이블을 추가 할 수 있습니다.

희망이 있습니다.