{"id":22877,"date":"2024-03-16T00:24:31","date_gmt":"2024-03-16T00:24:31","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/"},"modified":"2024-03-21T23:55:38","modified_gmt":"2024-03-21T23:55:38","slug":"in-depth-explanation-of-seekbar-slider-in-android-basics","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/","title":{"rendered":"In-depth explanation of SeekBar (slider) in Android basics."},"content":{"rendered":"<p>A SeekBar is a commonly used user interface component in Android that allows users to adjust the size of a value by dragging their finger. SeekBar is typically used for scenarios like adjusting volume and displaying progress bars.<\/p>\n<p>The steps for using SeekBar are as follows:<\/p>\n<ol>\n<li>Add a SeekBar control in the XML layout file.<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">SeekBar<\/span>\r\n    <span class=\"hljs-attr\">android:id<\/span>=<span class=\"hljs-string\">\"@+id\/seekBar\"<\/span>\r\n    <span class=\"hljs-attr\">android:layout_width<\/span>=<span class=\"hljs-string\">\"match_parent\"<\/span>\r\n    <span class=\"hljs-attr\">android:layout_height<\/span>=<span class=\"hljs-string\">\"wrap_content\"<\/span> \/&gt;<\/span>\r\n<\/code><\/pre>\n<ol>\n<li> Retrieve an instance of the SeekBar control in Java code and configure a listener:<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><span class=\"hljs-type\">SeekBar<\/span> <span class=\"hljs-variable\">seekBar<\/span> <span class=\"hljs-operator\">=<\/span> findViewById(R.id.seekBar);\r\nseekBar.setOnSeekBarChangeListener(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-title class_\">SeekBar<\/span>.OnSeekBarChangeListener() {\r\n    <span class=\"hljs-meta\">@Override<\/span>\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">onProgressChanged<\/span><span class=\"hljs-params\">(SeekBar seekBar, <span class=\"hljs-type\">int<\/span> progress, <span class=\"hljs-type\">boolean<\/span> fromUser)<\/span> {\r\n        <span class=\"hljs-comment\">\/\/ \u5f53SeekBar\u7684\u8fdb\u5ea6\u6539\u53d8\u65f6\u8c03\u7528\uff0c\u53c2\u6570progress\u8868\u793a\u5f53\u524d\u8fdb\u5ea6\u503c<\/span>\r\n        <span class=\"hljs-comment\">\/\/ \u5982\u679c\u662f\u7528\u6237\u62d6\u52a8\u5bfc\u81f4\u7684\u8fdb\u5ea6\u6539\u53d8\uff0c\u5219fromUser\u4e3atrue\uff0c\u5426\u5219\u4e3afalse<\/span>\r\n    }\r\n\r\n    <span class=\"hljs-meta\">@Override<\/span>\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">onStartTrackingTouch<\/span><span class=\"hljs-params\">(SeekBar seekBar)<\/span> {\r\n        <span class=\"hljs-comment\">\/\/ \u5f53\u7528\u6237\u5f00\u59cb\u62d6\u52a8SeekBar\u65f6\u8c03\u7528<\/span>\r\n    }\r\n\r\n    <span class=\"hljs-meta\">@Override<\/span>\r\n    <span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title function_\">onStopTrackingTouch<\/span><span class=\"hljs-params\">(SeekBar seekBar)<\/span> {\r\n        <span class=\"hljs-comment\">\/\/ \u5f53\u7528\u6237\u505c\u6b62\u62d6\u52a8SeekBar\u65f6\u8c03\u7528<\/span>\r\n    }\r\n});\r\n<\/code><\/pre>\n<ol>\n<li>Handle the progress change event of the SeekBar in the listener&#8217;s callback method.<\/li>\n<\/ol>\n<p>Some common properties and methods of the SeekBar are as follows:<\/p>\n<ol>\n<li>android:max: Set the maximum value of the SeekBar.<\/li>\n<li>Set the current progress value of the SeekBar using setProgress(int progress).<\/li>\n<li>Retrieve the current progress value of the SeekBar by calling getProgress().<\/li>\n<li>addListener to SeekBar.<\/li>\n<\/ol>\n<p>Important points to note:<\/p>\n<ol>\n<li>You can customize the style of the SeekBar according to your needs by changing properties such as the background and slider.<\/li>\n<li>In the callback method of the listener, relevant business logic can be executed as needed, such as updating the UI display of a progress bar or adjusting the volume.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>A SeekBar is a commonly used user interface component in Android that allows users to adjust the size of a value by dragging their finger. SeekBar is typically used for scenarios like adjusting volume and displaying progress bars. The steps for using SeekBar are as follows: Add a SeekBar control in the XML layout file. [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-22877","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>In-depth explanation of SeekBar (slider) in Android basics. - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"In-depth explanation of SeekBar (slider) in Android basics.\" \/>\n<meta property=\"og:description\" content=\"A SeekBar is a commonly used user interface component in Android that allows users to adjust the size of a value by dragging their finger. SeekBar is typically used for scenarios like adjusting volume and displaying progress bars. The steps for using SeekBar are as follows: Add a SeekBar control in the XML layout file. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-16T00:24:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-21T23:55:38+00:00\" \/>\n<meta name=\"author\" content=\"William Carter\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"William Carter\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\"},\"author\":{\"name\":\"William Carter\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/f697031891aacefc4b681d139781d3c0\"},\"headline\":\"In-depth explanation of SeekBar (slider) in Android basics.\",\"datePublished\":\"2024-03-16T00:24:31+00:00\",\"dateModified\":\"2024-03-21T23:55:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\"},\"wordCount\":191,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\",\"name\":\"In-depth explanation of SeekBar (slider) in Android basics. - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-16T00:24:31+00:00\",\"dateModified\":\"2024-03-21T23:55:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"In-depth explanation of SeekBar (slider) in Android basics.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/f697031891aacefc4b681d139781d3c0\",\"name\":\"William Carter\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1786698071dd8d74bec894b512f9e3c610c3a2a32985f67e688976cee3c8bbef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1786698071dd8d74bec894b512f9e3c610c3a2a32985f67e688976cee3c8bbef?s=96&d=mm&r=g\",\"caption\":\"William Carter\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/williamcarter\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"In-depth explanation of SeekBar (slider) in Android basics. - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/","og_locale":"en_US","og_type":"article","og_title":"In-depth explanation of SeekBar (slider) in Android basics.","og_description":"A SeekBar is a commonly used user interface component in Android that allows users to adjust the size of a value by dragging their finger. SeekBar is typically used for scenarios like adjusting volume and displaying progress bars. The steps for using SeekBar are as follows: Add a SeekBar control in the XML layout file. [&hellip;]","og_url":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-16T00:24:31+00:00","article_modified_time":"2024-03-21T23:55:38+00:00","author":"William Carter","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"William Carter","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/"},"author":{"name":"William Carter","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/f697031891aacefc4b681d139781d3c0"},"headline":"In-depth explanation of SeekBar (slider) in Android basics.","datePublished":"2024-03-16T00:24:31+00:00","dateModified":"2024-03-21T23:55:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/"},"wordCount":191,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/","url":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/","name":"In-depth explanation of SeekBar (slider) in Android basics. - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-16T00:24:31+00:00","dateModified":"2024-03-21T23:55:38+00:00","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/in-depth-explanation-of-seekbar-slider-in-android-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"In-depth explanation of SeekBar (slider) in Android basics."}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/f697031891aacefc4b681d139781d3c0","name":"William Carter","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1786698071dd8d74bec894b512f9e3c610c3a2a32985f67e688976cee3c8bbef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1786698071dd8d74bec894b512f9e3c610c3a2a32985f67e688976cee3c8bbef?s=96&d=mm&r=g","caption":"William Carter"},"url":"https:\/\/www.silicloud.com\/blog\/author\/williamcarter\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=22877"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22877\/revisions"}],"predecessor-version":[{"id":56823,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/22877\/revisions\/56823"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=22877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=22877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=22877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}