android - Remove side spacing from button in linearLayout -


i have layout designed far

enter image description here

notice side space around both buttons name "save" have marked red color, want remove spacing.

both buttons wrapped inside linearlayout orientation set "vertical", tried using layout_weight, marginleft , marginright no success.

here's how xml code looks buttons inside linearlayout

 <linearlayout         android:id="@+id/buttonsection"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"          >         <!--this layout save , change currency buttons-->           <button              android:id="@+id/savebutton"              android:layout_width="fill_parent"              android:layout_height="wrap_content"              android:text="save"              android:layout_weight="1"           />           <button              android:id="@+id/currencybutton"              android:layout_width="fill_parent"              android:layout_height="wrap_content"              android:text="save"              android:layout_weight="1"          />     </linearlayout> 

just information above linearlayout wrapped inside 1 more linearlayout controls layout of full activity

edit

full code main activity xml file

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"     android:layout_height="match_parent"      android:paddingtop="@dimen/activity_vertical_margin"     android:paddingbottom="@dimen/activity_vertical_margin"     android:background="@drawable/layer_list"     app:layout_behavior="@string/appbar_scrolling_view_behavior"     tools:showin="@layout/activity_main"     tools:context=".mainactivity"     android:orientation="vertical"     android:weightsum="5"     >      <linearlayout         android:id="@+id/layout1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         android:layout_weight="2"         android:paddingtop="10dp"         android:layout_marginbottom="30dp"         >          <linearlayout             android:id="@+id/leftcurrencysection"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="left"             android:layout_weight="1"             android:orientation="vertical"              >              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="gbp"                 android:textsize="30dp"                 android:textcolor="#ffffff"                 android:textallcaps="true"                 android:textstyle="bold"                 />              <edittext                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="0.00"                 android:textsize="30dp"                 android:textcolor="#ffffff"                 android:textallcaps="true"                 android:textstyle="bold"                 android:background="@null"                 />          </linearlayout>          <linearlayout             android:id="@+id/rightcurrencysection"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="right"             android:layout_weight="1"             android:orientation="vertical">              <textview                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:gravity="right"                 android:text="usd"                 android:textsize="30dp"                 android:textcolor="#ffffff"                 android:textallcaps="true"                 android:textstyle="bold"                 />              <edittext                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:gravity="right"                 android:text="0.00"                 android:textsize="30dp"                 android:textcolor="#ffffff"                 android:textallcaps="true"                 android:textstyle="bold"                 android:background="@null"                 />          </linearlayout>      </linearlayout>     <!--end of layout typing currency values-->      <linearlayout         android:id="@+id/buttonsection"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical"          >         <!--this layout save , change currency buttons-->               <button                 android:id="@+id/savebutton"                 android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:text="save"                 android:layout_weight="1"                 />                  <button                     android:id="@+id/currencybutton"                     android:layout_width="fill_parent"                     android:layout_height="wrap_content"                     android:text="save"                     android:layout_weight="1"                     />     </linearlayout>     <!--end of  save , change currency buttons-->      <!--begin layout calculator begin-->      <gridlayout          android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:columncount="3"         android:layout_gravity="center"         android:orientation="horizontal"         android:layout_weight="1"         >           <button android:text="1"              />          <button android:text="2" />          <button android:text="3" />            <button android:text="4" />          <button android:text="5" />          <button android:text="6" />            <button android:text="7" />          <button android:text="8" />          <button android:text="9" />           <button android:text="." />          <button android:text="0" />          <button android:text="del" />       </gridlayout>     <!--end layout calculator-->     <!--end layout calculator end-->   </linearlayout> 

there many people on here, pointed out mistake , guided me correct way of removing space either sides of button.

first i had remove padding parent linearlayout. removed paddingleft , paddingright. removed major part of space. cricket_007 pointing out.

even after removing space there still bit of space left out 1 or 2dp. apparently due default styling in android pointed out doug stevenson.

to remove last form of space, had apply sort of background mentioned eclipse example android:background="#00ff00"

applying above attribute removed space, due 9patch in android. learn more on here.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -