Barrier Barrier - 6 months ago 36
Android Question

Some buttons not showing up on RelativeLayout in Android

I use

RelativeLayout
to create a layout . In here I design layout like below. And I am using android studio.

enter image description here

This is my layout code,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/content24"
android:id="@+id/step19textView"
android:textSize="18dp"
android:textAlignment="center"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_marginTop="32dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<HorizontallScrollBar>
<LinearLayout
Orienteation= "horizontal";>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="1"
android:id="@+id/step19button1"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:background="@drawable/button_border"
android:layout_below="@+id/step19textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="50dp" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="2"
android:id="@+id/step19button2"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignTop="@+id/step19button1"
android:layout_toRightOf="@+id/step19button1"
android:layout_toEndOf="@+id/step19button1"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="3"
android:id="@+id/step19button3"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button2"
android:layout_toRightOf="@+id/step19button2"
android:layout_toEndOf="@+id/step19button2"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="4"
android:id="@+id/step19button4"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:textColor="@android:color/white"
android:layout_alignBottom="@+id/step19button3"
android:layout_toRightOf="@+id/step19button3"
android:layout_toEndOf="@+id/step19button3"
android:background="@drawable/button_border_5"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="5"
android:id="@+id/step19button5"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button4"
android:layout_toRightOf="@+id/step19button4"
android:layout_toEndOf="@+id/step19button4"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="6"
android:id="@+id/step19button6"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button5"
android:layout_toRightOf="@+id/step19button5"
android:layout_toEndOf="@+id/step19button5"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="7"
android:id="@+id/step19button7"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button6"
android:layout_toRightOf="@+id/step19button6"
android:layout_toEndOf="@+id/step19button6"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/step19button8"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button7"
android:layout_toRightOf="@+id/step19button7"
android:layout_toEndOf="@+id/step19button7"
android:background="@drawable/button_border"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:text="9"
android:id="@+id/step19button9"
android:textSize="13dp"
android:layout_marginLeft="3dp"
android:layout_alignBottom="@+id/step19button8"
android:layout_toRightOf="@+id/step19button8"
android:layout_toEndOf="@+id/step19button8"
android:background="@drawable/button_border"/>
</LinearLayout>
</HorizontalScrollBar>

<EditText
android:layout_width="wrap_content"
android:layout_height="20dp"
android:id="@+id/step19editText"
android:paddingLeft="10dp"
android:layout_below="@+id/step19button1"
android:layout_alignLeft="@+id/step19button1"
android:layout_alignStart="@+id/step19button1"
android:layout_marginTop="20dp" />

<EditText
android:layout_width="wrap_content"
android:layout_height="20dp"
android:id="@+id/step19editText2"
android:layout_alignTop="@+id/step19editText"
android:layout_centerHorizontal="true" />

<EditText
android:layout_width="wrap_content"
android:layout_height="20dp"
android:id="@+id/step19editText3"
android:paddingRight="10dp"
android:layout_alignTop="@+id/step19editText2"
android:layout_alignRight="@+id/step19button9"
android:layout_alignEnd="@+id/step19button9" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content25"
android:id="@+id/step19textView2"
android:textAlignment="textStart"
android:textSize="18dp"
android:paddingLeft="10dp"
android:layout_alignTop="@+id/step19textView4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content26"
android:id="@+id/step19textView4"
android:textSize="18dp"
android:textAlignment="center"
android:layout_alignTop="@+id/step19textView5"
android:layout_centerHorizontal="true" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content27"
android:id="@+id/step19textView5"
android:textSize="18dp"
android:textAlignment="textEnd"
android:paddingRight="10dp"
android:layout_below="@+id/step19editText3"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Next "
android:textSize="18dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:id="@+id/step19nextbutton"
android:layout_marginTop="59dp"
android:textColor="@android:color/white"
android:background="@drawable/button_border_5"
android:layout_below="@+id/step19textView4"
android:layout_centerHorizontal="true" />

</RelativeLayout>


When I attempt to run this on Samsung Galaxy S Duos 3 (http://www.gsmarena.com/samsung_galaxy_s_duos_3-6662.php), 8 & 9 buttons are not showing though design is look like that.

I want show all buttons look like on the image .
Have any ideas about this ?

Thank you.

Answer

Try this just replace you xml to this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/content24"
    android:id="@+id/step19textView"
    android:textSize="18dp"
    android:textAlignment="center"
    android:paddingRight="10dp"
    android:paddingLeft="10dp"
    android:paddingBottom="10dp"
    android:paddingTop="10dp"
    android:layout_marginTop="32dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<LinearLayout
    android:id="@+id/llParent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/step19textView"
    android:layout_marginTop="50dp"
    android:orientation="horizontal">

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="1"
        android:id="@+id/step19button1"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_weight="1"
        android:background="@drawable/button_border"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        />

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="2"
        android:id="@+id/step19button2"
        android:layout_weight="1"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_alignTop="@+id/step19button1"
        android:layout_toRightOf="@+id/step19button1"
        android:layout_toEndOf="@+id/step19button1"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="3"
        android:layout_weight="1"
        android:id="@+id/step19button3"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_alignBottom="@+id/step19button2"
        android:layout_toRightOf="@+id/step19button2"
        android:layout_toEndOf="@+id/step19button2"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="4"
        android:id="@+id/step19button4"
        android:textSize="13dp"
        android:layout_weight="1"
        android:layout_marginLeft="3dp"
        android:textColor="@android:color/white"
        android:layout_alignBottom="@+id/step19button3"
        android:layout_toRightOf="@+id/step19button3"
        android:layout_toEndOf="@+id/step19button3"
        android:background="@drawable/button_border_5"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="5"
        android:id="@+id/step19button5"
        android:textSize="13dp"
        android:layout_weight="1"
        android:layout_marginLeft="3dp"
        android:layout_alignBottom="@+id/step19button4"
        android:layout_toRightOf="@+id/step19button4"
        android:layout_toEndOf="@+id/step19button4"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="6"
        android:id="@+id/step19button6"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_weight="1"
        android:layout_alignBottom="@+id/step19button5"
        android:layout_toRightOf="@+id/step19button5"
        android:layout_toEndOf="@+id/step19button5"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="7"
        android:id="@+id/step19button7"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_weight="1"
        android:layout_alignBottom="@+id/step19button6"
        android:layout_toRightOf="@+id/step19button6"
        android:layout_toEndOf="@+id/step19button6"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="8"
        android:layout_weight="1"
        android:id="@+id/step19button8"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_alignBottom="@+id/step19button7"
        android:layout_toRightOf="@+id/step19button7"
        android:layout_toEndOf="@+id/step19button7"
        android:background="@drawable/button_border"/>

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="9"
        android:layout_weight="1"
        android:id="@+id/step19button9"
        android:textSize="13dp"
        android:layout_marginLeft="3dp"
        android:layout_alignBottom="@+id/step19button8"
        android:layout_toRightOf="@+id/step19button8"
        android:layout_toEndOf="@+id/step19button8"
        android:background="@drawable/button_border"/>
</LinearLayout>


<EditText
    android:layout_width="wrap_content"
    android:layout_height="20dp"
    android:id="@+id/step19editText"
    android:paddingLeft="10dp"
    android:layout_below="@+id/llParent"
    android:layout_alignLeft="@+id/llParent"
    android:layout_alignStart="@+id/llParent"
    android:layout_marginTop="20dp" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="20dp"
    android:id="@+id/step19editText2"
    android:layout_alignTop="@+id/step19editText"
    android:layout_centerHorizontal="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="20dp"
    android:id="@+id/step19editText3"
    android:paddingRight="10dp"
    android:layout_alignTop="@+id/step19editText2"
    android:layout_alignRight="@+id/llParent"
    android:layout_alignEnd="@+id/llParent" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/content25"
    android:id="@+id/step19textView2"
    android:textSize="18dp"
    android:paddingLeft="10dp"
    android:layout_alignTop="@+id/step19textView4"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/content26"
    android:id="@+id/step19textView4"
    android:textSize="18dp"
    android:textAlignment="center"
    android:layout_alignTop="@+id/step19textView5"
    android:layout_centerHorizontal="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/content27"
    android:id="@+id/step19textView5"
    android:textSize="18dp"

    android:paddingRight="10dp"
    android:layout_below="@+id/step19editText3"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<Button
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="    Next    "
    android:textSize="18dp"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:id="@+id/step19nextbutton"
    android:layout_marginTop="59dp"
    android:textColor="@android:color/white"
    android:background="@drawable/button_border_5"
    android:layout_below="@+id/step19textView4"
    android:layout_centerHorizontal="true" />

</RelativeLayout>
Comments