{"id":27907,"date":"2015-06-25T18:32:05","date_gmt":"2015-06-25T18:32:05","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=27907"},"modified":"2015-06-25T18:32:05","modified_gmt":"2015-06-25T18:32:05","slug":"how-to-add-element-below-another-in-relative-layout-in-android","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/","title":{"rendered":"How to add element below another in relative layout in android"},"content":{"rendered":"<p>To set an element like TextView below another TextView in RelativeLayout in android app is easy to do with layout xml. You can do it like this.<\/p>\n<pre class=\"brush:xml\">&lt;TextView\r\n\tandroid:id=\"@+id\/heading\"\r\n\tandroid:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n\tandroid:text=\"@string\/activity_action_title\"\r\n\tandroid:textAppearance=\"?android:attr\/textAppearanceLarge\"\/&gt;\r\n&lt;TextView\r\n        android:id=\"@+id\/welcome\"\r\n\tandroid:layout_width=\"wrap_content\"\r\n\tandroid:layout_height=\"wrap_content\"\r\n\tandroid:layout_below=\"@+id\/heading\"\r\n\tandroid:layout_marginTop=\"10dp\"\r\n\tandroid:textAppearance=\"?android:attr\/textAppearanceMedium\"\/&gt;<\/pre>\n<p>in the above code welcome TextView will come after heading.<\/p>\n<p>Now we will do it programatically.<\/p>\n<pre class=\"brush:java\">TextView ResultText = new TextView(Activity.this);\r\nResultText.setText(\"Your Custom text.\");\r\nRelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);\r\np.addRule(RelativeLayout.BELOW, R.id.heading);\r\nResultText.setLayoutParams(p);                    \r\nView relativeLayout = findViewById(R.id.Header);\r\n((RelativeLayout) relativeLayout).addView(ResultText);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To set an element like TextView below another TextView in RelativeLayout in android app is easy to do with layout xml. You can do it like this. &lt;TextView android:id=&#8221;@+id\/heading&#8221; android:layout_width=&#8221;wrap_content&#8221; android:layout_height=&#8221;wrap_content&#8221; android:text=&#8221;@string\/activity_action_title&#8221; android:textAppearance=&#8221;?android:attr\/textAppearanceLarge&#8221;\/&gt; &lt;TextView android:id=&#8221;@+id\/welcome&#8221; android:layout_width=&#8221;wrap_content&#8221; android:layout_height=&#8221;wrap_content&#8221; android:layout_below=&#8221;@+id\/heading&#8221; android:layout_marginTop=&#8221;10dp&#8221; android:textAppearance=&#8221;?android:attr\/textAppearanceMedium&#8221;\/&gt; in the above code welcome TextView will come after heading. Now we will do it <a href=\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[271,599],"tags":[221,1899,1898],"class_list":["post-27907","post","type-post","status-publish","format-standard","hentry","category-android-2","category-magento-1-8","tag-android","tag-below","tag-relativelayout"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to add element below another in relative layout in android - Webkul Blog<\/title>\n<meta name=\"description\" content=\"How to add element below another in relative layout in android\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add element below another in relative layout in android - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"How to add element below another in relative layout in android\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2015-06-25T18:32:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ratnesh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ratnesh\" \/>\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:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\"},\"author\":{\"name\":\"Ratnesh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/98fa964dace2c6affe08c231d20914f7\"},\"headline\":\"How to add element below another in relative layout in android\",\"datePublished\":\"2015-06-25T18:32:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\"},\"wordCount\":54,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"android\",\"below\",\"relativelayout\"],\"articleSection\":[\"Android\",\"Magento 1.8\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\",\"name\":\"How to add element below another in relative layout in android - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2015-06-25T18:32:05+00:00\",\"description\":\"How to add element below another in relative layout in android\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to add element below another in relative layout in android\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/98fa964dace2c6affe08c231d20914f7\",\"name\":\"Ratnesh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/87f852615fec6dd5521718a501298d8eeba3c4882fea89c1eda3b272e53406d3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/87f852615fec6dd5521718a501298d8eeba3c4882fea89c1eda3b272e53406d3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ratnesh\"},\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/ratnesh\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to add element below another in relative layout in android - Webkul Blog","description":"How to add element below another in relative layout in android","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:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/","og_locale":"en_US","og_type":"article","og_title":"How to add element below another in relative layout in android - Webkul Blog","og_description":"How to add element below another in relative layout in android","og_url":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2015-06-25T18:32:05+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Ratnesh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ratnesh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/"},"author":{"name":"Ratnesh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/98fa964dace2c6affe08c231d20914f7"},"headline":"How to add element below another in relative layout in android","datePublished":"2015-06-25T18:32:05+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/"},"wordCount":54,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["android","below","relativelayout"],"articleSection":["Android","Magento 1.8"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/","url":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/","name":"How to add element below another in relative layout in android - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2015-06-25T18:32:05+00:00","description":"How to add element below another in relative layout in android","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-add-element-below-another-in-relative-layout-in-android\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to add element below another in relative layout in android"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/98fa964dace2c6affe08c231d20914f7","name":"Ratnesh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/87f852615fec6dd5521718a501298d8eeba3c4882fea89c1eda3b272e53406d3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/87f852615fec6dd5521718a501298d8eeba3c4882fea89c1eda3b272e53406d3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ratnesh"},"sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/ratnesh\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/27907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=27907"}],"version-history":[{"count":1,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/27907\/revisions"}],"predecessor-version":[{"id":27908,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/27907\/revisions\/27908"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=27907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=27907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=27907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}