Seekbar background customization is a troublesome thing, and it is best to use shapedrawable to customize (so that can be arbitrarily stretched), if the direct use of pictures, then the attention of the matter will be many, otherwise the general situation always have a variety of unhappy. Recently done UI encountered Seekbar must use the picture to fill the situation, the definition of the size of the time a lot of effort. Effects such as:
Obviously a background map and thumb, no progress, and with the screen adaptation of the problem, a great effort.
Incidentally, in many cases, such as button, Seekbar, ImageButton, ImageView and so on wrap_content set background, the image appears unexpectedly stretched or shrunk, In fact, because the image in the drawable directory is not caused (instead of setting minheight and minwidth problems, setting this does solve the problem, but the image may become blurred because of the tension, because it is not caused by this, the root cause to be clear), The author of this project is in the screen density of 160dpi car running, the corresponding drawable should be placed in the MDPI folder, at the beginning I was placed in the hdpi (240dpi) folder, the background display on the car, will shrink 1/3, because Android loading pictures , already according to the directory to help you calculate how many DP on the screen should be displayed, for example, in the HPI folder 100px pictures, Android will think you are running on the 240dpi screen, to show the 100px, Should be 66.7DP length, then if you run in a 160dpi device, the effect is still 66.7dp, that is, 66.7px
My final layout parameters are:
<SeekBar Android:id= "@+id/splash"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:minheight= "145DP"Android:maxheight= "145DP"Android:maxwidth= "482DP"Android:minwidth= "482DP"android:progressdrawable= "@drawable/radio_dash"Android:thumb= "@drawable/radio_dash_drag"android:progress= "20"Android:max= "100"Android:paddingleft= "1DP"Android:paddingright= "1DP"Android:thumboffset= "1DP"/>
where Min and max two parameters determine the final length width of the component, Layout_width and height if also set to a fixed value, if the slider is larger than the background, the extra portion is not displayed. Thumboffset is the starting part of the slider relative to the background, set to 0 the left edge of the slider is aligned with the left edge of the background, and a positive value expand the background, and you need to set the padding to show the sliders for the expand background. The effect of aligning the center of the slider with the starting point of the background.
Finally finished ... Do the spectators gentlemen understand? Have better ideas welcome to share together.
Essentials of dimension definition for Seekbar