I'm an absolutely new coder, and I'm trying to design a short-side-of-the-screen navigation bar for an application that forces landscape view and allows the Android nav bar to be seen. This basically comes down to creating a vertical button bar on the left side of the screen, and to maintain adaptability, I've decided to structure it with layout_weight within a LinearLayout block. Here's the relevant code:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageButton
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:padding="0dp"
android:background="@android:color/black"
android:src="@drawable/navbut1null" />
<ImageButton
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:padding="0dp"
android:background="@android:color/black"
android:src= "@drawable/navbut2null" />
<ImageButton
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:padding="0dp"
android:background="@android:color/black"
android:src= "@drawable/navbut3null" />
<ImageButton
style="?android:attr/borderlessButtonStyle"
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:padding="0dp"
android:background="@android:color/black"
android:src= "@drawable/navbut4null" />
</LinearLayout>
My problem is that these image buttons don't align perfectly in size, but instead either the bottom two buttons extrude by an extra pixel versus the top two (with this exact code) or vice-versa (when I replace the layout_height="0dp" with layout_height="match_parent"). Here's a picture:
(https://i.stack.imgur.com/2xReC.png) (Sorry that I can't embed - I have 0 reputation)
It's subtle, but you may notice the extrusion of the bottom two buttons. In fact, without setting the background to black on all the buttons, the top two buttons develop thin white margins above and below them, and I think this has to do with whatever is going on here.
So what's going on? What would you advise I do? My goal is a twitter-style navbar.