0

I'm working on an Android app where one of the activities will have the following layout:

Layout

XML Code of this activity:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.bugdroid.sintomas1.Motivo_sintoma">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_below="@+id/linearLayout3"
    android:layout_alignParentStart="true">

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="123dp" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/linearLayout2">

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="123dp" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_below="@+id/linearLayout2"
    android:layout_alignParentStart="true"
    android:id="@+id/linearLayout3">

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="123dp" />

    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent" />

</LinearLayout>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button9"
    android:layout_marginRight="0dip"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_toEndOf="@+id/button10" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button10"
    android:layout_alignTop="@+id/button9"
    android:layout_alignParentStart="true" />

I want the layout to look this mockup:

Desired result

I also want to remove it on the buttons at the bottom and join them into one as see on the image.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Can you check if [this](http://stackoverflow.com/questions/29365268/how-to-remove-default-layouts-padding-margin) solves your issue? – Bonatti May 30 '16 at 18:11
  • It does not, i removed those properties from XML – Duarte Andrade May 30 '16 at 18:15
  • Do not remove, instead, set as 0dp (density pixel). Or even use the padding in that View, such as `android:padding="0dp"` in each LinearLayout – Bonatti May 30 '16 at 18:19
  • Thanks but It didnt worked – Duarte Andrade May 30 '16 at 18:29
  • Something is wrong... The Buttons "should" not clip each other, so that the user does not misclick it. The padding and margin should give the desired effect you seek. With developer options on, click "Show Layout delimiters" or `Exibir limitadores de Layout` and check if the Layout is behaving as expected. As far as I can tell, the layout is correct, however the "appeareance" is that there is a blank space in between buttons. Paint the button some color, or use any Theme, to check its real box size. – Bonatti May 30 '16 at 19:33
  • Also, please, review your Layout. (It appears you are using Android Studio) Check the other VIewGroups, specially `TableLayout` and `GridLayout`. Try to keep under `80` Views in a layout file, for performance reasons. – Bonatti May 30 '16 at 19:35

1 Answers1

0

The issue is in Button background. Default background is the following (file btn_default.xml in platform resources):

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/btn_default_normal_disable" />
    <item android:state_pressed="true" 
        android:drawable="@drawable/btn_default_pressed" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_default_selected" />
    <item android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_focused="true"
        android:drawable="@drawable/btn_default_normal_disable_focused" />
    <item
         android:drawable="@drawable/btn_default_normal_disable" />
</selector>

All items are 9patches. So, I would suggest to use Your own backgrounds (or modify platform backgrounds and remove paddings using 9patch tool

Stanojkovic
  • 1,612
  • 1
  • 17
  • 24