【问题标题】:Is there a way to move the calendar of a datePicker in spinner mode?有没有办法在微调模式下移动 datePicker 的日历?
【发布时间】:2016-06-27 22:03:33
【问题描述】:

我正在寻找这样的东西。我有大量的垂直屏幕空间,我喜欢日历与应用程序的配合方式,但我希望用户也有一个今年的微调器。我只是想知道是否有办法移动日历(如果可能的话),以便能够看到年份微调器。

【问题讨论】:

    标签: android datepicker calendar spinner


    【解决方案1】:

    只需将 pickerMode 添加到 XML 文件中的 DatePicker 即可:

    <DatePicker
    ...
    android:datePickerMode="spinner" />
    

    【讨论】:

    • 我已经在微调模式下拥有它。我在问是否有办法将日历移到下面,以便显示年份微调器。
    【解决方案2】:

    或者您可以添加一个更可定制的弹出对话框。如果您使用弹出对话框,那么与微调器相比,您必须处理更多案例。

    并且在视图的onclick事件中,附加popupwindow

       PopupWindow yourDatePopup = datePopupWindow();
       //this line will give a spinner effect
       yourDatePopup.showAsDropDown(clickableView, -7, 0);
    
       public PopupWindow datePopupWindow() {
    
        PopupWindow popupWindow = new PopupWindow(this);
        popupWindow.setFocusable(true);
        popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        // set the list view as pop up window content
        //Define your dateview
        popupWindow.setContentView(yourDateView);
        popupWindow.setOutsideTouchable(true);
        return popupWindow;
      }
    

    注意:- 只是为了帮助,而不是确切的代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-08
      相关资源
      最近更新 更多