ShawnLin013 / NumberPicker

:slot_machine: The android library that provides a simple and customizable NumberPicker.
MIT License
1.07k stars 240 forks source link

Position and dimension #163

Open gaminn opened 4 years ago

gaminn commented 4 years ago

I have this simple layout:

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="300dp"
            android:background="@color/colorTransparent">
                <com.shawnlin.numberpicker.NumberPicker
                    android:id="@+id/picker"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:np_width="96dp"
                    app:np_height="270dp"
                    app:np_textSize="40dp"
                    app:np_selectedTextSize="43dp"
                    app:np_dividerThickness="0dp"
                    app:np_dividerColor="@color/colorText"
                    app:np_max="59"
                    app:np_min="0"
                    app:np_selectedTextColor="@color/colorText"
                    app:np_textColor="@color/colorText"
                    app:np_wheelItemCount="3"
                    app:np_value="3"
                    app:np_maxFlingVelocityCoefficient="2" />
        </RelativeLayout>

It NumberPicker sitting inside 300dp high RelativeLayout. The RelativeLayout has some background to visualize space it occupies. With this layout, the NumberPicker is drawn in a way that it is missing half of the upper digit (it is drawn outside the RelativeLayout). I can only fix that by adding some top margin to NumberPicker which is a workaround. Is that a bug?

Also I have a hard time to understand np_width and np_height. Why are they another width and height attributes if we already have android:layout_width and android:layout_height?