I am trying to use a NumberPicker in a dialog.
When i add the NumberPicker to the view it looks like follows:
My xml-file for the Dialog looks pretty simple like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/numberPicker"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
My code is simply:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = (LayoutInflater)builder.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout inflated = (RelativeLayout)inflater.inflate(R.layout.dialog_button_delay, (ViewGroup)getView());
final NumberPicker pick = (NumberPicker) inflated.findViewById(R.id.numberPicker);
String[] minuteValues = new String[37];
for (int i = 0; i < minuteValues.length; i++) {
minuteValues[i] = String.valueOf(i*5);
}
pick.setWrapSelectorWheel(false);
pick.setMinValue(0);
pick.setMaxValue(36);
pick.setDisplayedValues(minuteValues);
builder.setView(inflated);
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.familyfood.familyfood">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity
android:name=".MainActivity"
android:label="@string/title_start">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".AddFoodActivity" />
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login"/>
</application>
</manifest>
Styles xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
Adding android:theme="@android:style/Theme.Dialog"
results in the following visual:
Does anyone have an idea why i can't use the MaterialDesign NumberPicker?