18

On upgrade to Android Studio 3.1 there is no TimePicker in the layout editor palette.
Search doesn't find it.
In fact all of the picker controls seem to have vanished. They were there in 3.0.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Mike James
  • 749
  • 6
  • 9
  • Yeah, I don't see it anymore. I and most (all?) people I know who use android studio use the text editor, not the graphical editor (the "Text" tab instead of the "Design" tab at the bottom of the window). In there, if you start typing ` – hBrent Mar 30 '18 at 22:40
  • I had an idea that this must be true due to the lack of complaints. I find the layout editor very easy to use for a first attempt at a UI. I have filed a bug report because if you do use the layout editor its just been crippled with out anyone mentioning it. – Mike James Mar 31 '18 at 08:59
  • Once you add the TimePicker in the text view of the editor, you can then switch to the design view (what you're calling the layout editor) and manipulate/edit the TimePicker the way you want. – hBrent Mar 31 '18 at 18:40
  • Yes that works and if you set a width and height you can then use the Layout Editor to work with it. This makes it even more silly that these aren't in the palette. – Mike James Apr 01 '18 at 08:53
  • there is no word from AS team yet on how to bring this back. – user1506104 Apr 03 '18 at 07:58
  • 2
    No word - my bug report https://issuetracker.google.com/issues/76403152 has a date of 31st March and no response as yet. This is fairly typical for bug reports I have filed in the past and is one of the reasons I don't often bother. What usually happens next is a request for a lot of irrelevant details. – Mike James Apr 03 '18 at 13:38
  • Widget are missing in Android Studio 3.1 so you have to wait for new update from Android studio team. For more info please check this article: http://www.i-programmer.info/news/193/11668.html – Nik Apr 05 '18 at 10:39
  • 3
    I'm the person who wrote that news item and asked the question. I noticed that they were missing but have no information on why they are missing or if the Android team intends to put them back - which is what we need to know. – Mike James Apr 05 '18 at 16:58

3 Answers3

6

I am not sure where to find it in the selection menu but if you just need a time picker in your project you can select the Text tab on the bottom of your activity.xml file and paste the TimePicker xml.

<TimePicker
android:id="@+id/simpleTimePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"/>

Then you can select which timePickerMode you want if you want a clock then change spinner with clock.

Hope this helps.

luckyging3r
  • 3,047
  • 3
  • 18
  • 37
2

As stated in the other answers, there is comment in the release notes about the improvements in the palette.

https://developer.android.com/studio/releases/index.html#layout_editor

For some unknown reason the @Widget annotation cannot be located in the project. Android annotation package TimePicker class

A dirty trick I made, is to create my own @Widget annotation copying their code and then add it to a custom class which inherits from TimePicker, of course this is just if you are eager to have it in the Palette of your project xD

example: Widget.java

package com.example.ctuser1.myapplication;

import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.SOURCE)
public @interface Widget {
}

MyTimePicker.java

package com.example.ctuser1.myapplication;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TimePicker;

@Widget
public class MyTimePicker extends TimePicker {
  public MyTimePicker(Context context) {
      super(context);
  }

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

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

}

Result:

Result in design Palette

aaroncio
  • 307
  • 1
  • 6
  • You don't need to do this - its far too complicated. Just paste the start of the XML for the missing widget and then use the layout editor. – Mike James Apr 06 '18 at 17:15
  • Yes, I agree, the effort is not worthy compared to just add the XML, the fix must be done by the Android Studio devs but if you want to add it right now and use it in the palette this is a way to do it. – aaroncio Apr 06 '18 at 17:21
  • I think I should say that the answer is interesting - just not something worth doing if all you want to do is use the missing widgets. – Mike James Apr 06 '18 at 17:37
1

The Android Studio 3.1 release notes state that

Palette in the Layout Editor has received many improvements

It also states that there was

Reorganization of categories for views and layouts.

So changes to this section were planned for this release. This makes me speculate that removal of the pickers is purposeful.

This reorganization of the palette was noticed prior to final release of Android Studio 3.1 and a bug was filed. Although the bug was assigned no comment was added.

One of the bugs submitted for this issue has been assigned to a Googler. Again this isn't an official sign either way.

Jade
  • 3,156
  • 1
  • 34
  • 44
  • Yes the reorganization was on purpose but did they mean to leave out all of the picker and all of the transitions. There is no way to know if the omissions are by accident. There is also no reason for dropping these widgets. What we want to know is if they omission is on purpose and what the AS team expect use to do about not having access to widgets that we have been using. – Mike James Apr 06 '18 at 17:13
  • My own bug report is also being ignored. I'm very surprised that nothing is being done. This isn't a small omission and its easy to understand and fix - either by putting the widgets back or making clear that they are deprecated. – Mike James Apr 06 '18 at 17:18