I have a RecyclerView that each row of that has a GridLayout. I inserted some rows (about 10) in the RecyclerView. It scrolls smoothly in Nexus 5 and Nexus 7 and Sony. But when I run it on Samsung Note 4, it scrolls very slowly and with lots of lag!!
This is my layout for each row:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:orientation="vertical"
app:columnCount="4"
>
<TextView
android:id="#+id/start_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="left|center_vertical"
app:layout_row="0"
app:layout_column="0"
android:textAppearance="#style/TextAppearance.AppCompat.Caption"
android:text="test"
/>
<View
android:layout_width="1dp"
android:layout_height="0dp"
app:layout_row="0"
app:layout_column="1"
app:layout_rowSpan="3"
app:layout_gravity="fill"
android:background="#color/dim_foreground_disabled_material_dark"
/>
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_row="0"
app:layout_column="2"
android:singleLine="true"
app:layout_gravity="right|center_vertical|fill"
android:textAppearance="#style/TextAppearance.AppCompat.Title"
android:ellipsize="end"
android:layout_margin="10dp"
android:text="test"
/>
<ImageView
android:id="#+id/event_icon"
android:layout_width="32dp"
android:layout_height="32dp"
app:layout_row="0"
app:layout_column="3"
app:layout_gravity="center_vertical"
android:src="#mipmap/ic_launcher"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_row="1"
app:layout_column="1"
app:layout_columnSpan="2"
app:layout_gravity="center_horizontal|center_vertical"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_gravity="center_horizontal|center_vertical|fill"
android:textAppearance="#style/TextAppearance.AppCompat.Body1"
android:textColor="#color/button_material_dark"
android:layout_margin="6dp"
android:text="test"
/>
<ImageView
android:id="#+id/imageView1"
android:layout_width="25dp"
android:layout_height="25dp"
app:layout_gravity="center_horizontal|center_vertical"
android:src="#mipmap/ic_supervisor_account_black_24dp"/>
</LinearLayout>
<TextView
android:id="#+id/end_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_row="2"
app:layout_column="0"
app:layout_gravity="left|center_vertical"
android:paddingRight="10dp"
android:textAppearance="#style/TextAppearance.AppCompat.Caption"
android:text="test"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_row="2"
app:layout_column="2"
app:layout_gravity="right|center_vertical"
android:textAppearance="#style/TextAppearance.AppCompat.Caption"
android:textColor="#color/button_material_dark"
android:layout_margin="10dp"
android:text="test"
/>
<ImageView
android:id="#+id/imageView2"
android:layout_width="15dp"
android:layout_height="15dp"
app:layout_gravity="center_vertical"
app:layout_row="2"
app:layout_column="3"
android:src="#mipmap/location"/>
<ProgressBar
android:id="#+id/time_progressbar"
app:layout_row="3"
app:layout_column="0"
app:layout_columnSpan="3"
app:layout_gravity="fill"
android:max="100"
android:progress="100"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="false" />
<TextView
android:id="#+id/time_text_view"
app:layout_row="3"
app:layout_column="3"
app:layout_gravity="right|center_vertical|fill"
android:textAppearance="#style/TextAppearance.AppCompat.Caption"
android:text="test"
/>
</android.support.v7.widget.GridLayout>
How can I fix this problem?
Related
Whenever I run this program on Emulator, the positions of the widgets change, I tried changing the emulator, size of the layout(Device For Preview), but it wasn't helpful. Please Help me Out.
One solution I got was by decreasing the size of widgets, and arranging widgets to the top of the layout, but it was very time consuming. Also any widget placed at the bottom of the layout wouldn't even show up in the Emulator.
Layout
Emulator
XML file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".button">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/addition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="76dp"
android:layout_marginEnd="116dp"
android:background="#D2F0FD"
android:padding="15dp"
android:text="10 + 5"
android:textColor="#000000"
android:textSize="30dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/scoreBoard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="23dp"
android:layout_marginEnd="273dp"
android:background="#F44336"
android:padding="10dp"
android:text="0/0"
android:textSize="25dp" />
<TextView
android:id="#+id/result"
android:layout_width="183dp"
android:layout_height="61dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="487dp"
android:layout_marginEnd="49dp"
android:layout_marginBottom="92dp"
android:padding="5dp"
android:text="result"
android:textSize="30dp" />
<Button
android:id="#+id/play"
android:layout_width="127dp"
android:layout_height="64dp"
android:layout_marginStart="150dp"
android:layout_marginTop="-417dp"
android:layout_marginEnd="133dp"
android:layout_marginBottom="528dp"
android:onClick="playAgain"
android:text="Play Again!"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="18dp"
android:layout_marginTop="23dp"
android:layout_marginEnd="26dp"
android:background="#FF9800"
android:padding="10dp"
android:text="30s"
android:textSize="25dp" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="167dp"
android:layout_marginEnd="0dp"
android:layout_marginBottom="182dp"
app:columnCount="2"
app:rowCount="2">
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2196F3"
android:onClick="chosAns"
android:tag="1"
android:text="Button"
android:textSize="30dp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0"
app:layout_rowWeight="1" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#E80909"
android:onClick="chosAns"
android:tag="2"
android:text="Button"
android:textSize="30dp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0"
app:layout_rowWeight="1" />
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#62F806"
android:onClick="chosAns"
android:tag="3"
android:text="Button"
android:textSize="30dp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1"
app:layout_rowWeight="1" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#8448E4"
android:onClick="chosAns"
android:tag="4"
android:text="Button"
android:textSize="30dp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1"
app:layout_rowWeight="1" />
</androidx.gridlayout.widget.GridLayout>
<Button
android:id="#+id/go"
android:layout_width="268dp"
android:layout_height="146dp"
android:layout_marginStart="64dp"
android:layout_marginTop="433dp"
android:background="#3FED46"
android:onClick="hideIt"
android:text="GO!!"
android:textSize="60dp"
android:visibility="invisible" />
</RelativeLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Because you are nesting Constraint Layout with Relative Layout which contains widget that may lead to overflowing.
I am trying to build Tic Tac Toe app using a tutorial.I am stuck at one part.I have a GridLayout having 9 ImageView in 3 rows and 3 column.Have a look at my activity_main xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.v7.widget.GridLayout
android:id="#+id/gridLayout"
android:layout_width="315dp"
android:layout_height="333dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/matrix"
app:columnCount="3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.454"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.562"
app:rowCount="3">
<ImageView
android:id="#+id/imageView1"
android:layout_width="82dp"
android:layout_height="70dp"
android:layout_marginTop="18dp"
android:layout_marginBottom="10dp"
android:onClick="onclick"
android:tag="0"
app:layout_column="0"
app:layout_row="0" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="130dp"
android:layout_height="73dp"
android:layout_marginTop="15dp"
android:onClick="onclick"
android:tag="1"
app:layout_column="1"
app:layout_row="0" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="87dp"
android:layout_height="74dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:onClick="onclick"
android:tag="2"
app:layout_column="2"
app:layout_row="0" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="82dp"
android:layout_height="70dp"
android:layout_marginTop="18dp"
android:layout_marginBottom="10dp"
android:onClick="onclick"
android:tag="3"
app:layout_column="0"
app:layout_row="1" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="130dp"
android:layout_height="73dp"
android:layout_marginTop="15dp"
android:onClick="onclick"
android:tag="4"
app:layout_column="1"
app:layout_row="1" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="87dp"
android:layout_height="74dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:onClick="onclick"
android:tag="5"
app:layout_column="2"
app:layout_row="1" />
<ImageView
android:id="#+id/imageView7"
android:layout_width="82dp"
android:layout_height="70dp"
android:layout_marginTop="22dp"
android:layout_marginBottom="10dp"
android:onClick="onclick"
android:tag="6"
app:layout_column="0"
app:layout_row="2" />
<ImageView
android:id="#+id/imageView8"
android:layout_width="130dp"
android:layout_height="73dp"
android:layout_marginTop="20dp"
android:onClick="onclick"
android:tag="7"
app:layout_column="1"
app:layout_row="2" />
<ImageView
android:id="#+id/imageView9"
android:layout_width="87dp"
android:layout_height="74dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="15dp"
android:onClick="onclick"
android:tag="8"
app:layout_column="2"
app:layout_row="2" />
</android.support.v7.widget.GridLayout>
<LinearLayout
android:id="#+id/linearlayout"
android:layout_width="276dp"
android:layout_height="176dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.355">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="93dp"
android:text="TextView"
android:textSize="20sp" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="70dp"
android:onClick="playagain"
android:text="#string/button"
android:textSize="24sp" />
</LinearLayout>
To empty the already drawn image in GridLayout I used this.But the app's getting crashed can anyone tell me if it's correct
enter code here
public void playagain(View view)
{
GridLayout gridLayout = (GridLayout)findViewById(R.id.gridLayout);
for (int i = 0; i< gridLayout.getChildCount(); i++)
{
((ImageView)gridLayout.getChildAt(i)).setImageResource(0);
}
}
Here's the image of my logcat
You have to import android.support.v7.widget.GridLayout instead of importing android.widget.GridLayout in your class.
Sup?
You can try to change your code from
GridLayout gridLayout = (GridLayout)findViewById(R.id.gridLayout);
to
android.support.v7.widget.GridLayout gridLayout = (android.support.v7.widget.GridLayout)findViewById(R.id.gridLayout);
Use
android.support.v7.widget.GridLayout
instead of
GridLayout
I'm using android studio to create a simple calculator app using the GridLayout. However, it's not displaying on my device (yes, running it on my old note5 rather than emulator because it's goes a lot faster). In android studio in the design tab of the xml file it shows how I'd expect it to be, however when I run the app on my phone, thing's are a little weird. I'll post the screenshot of the app running on my phone as well as a screenshot of android studio design tab. I'll also post my full xml code in my activity_main.xml.
My Phone:
Android Studio:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.pvtboromeo.test.MainActivity"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/editText"
android:background="#android:color/black"
android:textColor="#android:color/white"
android:layout_row="0"
android:layout_column="0"
android:layout_columnSpan="4"
android:layout_rowSpan="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:enabled="false"
android:gravity="bottom|right"
android:paddingRight="15sp"
android:paddingBottom="15sp"
android:textAlignment="gravity"
android:textSize="40sp"
android:text="TEST" />
<Button
android:id="#+id/buttonC"
android:layout_column="0"
android:layout_row="2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="C"/>
<Button
android:id="#+id/buttonNegative"
android:layout_column="1"
android:layout_row="2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="+/-"/>
<Button
android:id="#+id/buttonPercent"
android:layout_row="2"
android:layout_column="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="%" />
<Button
android:id="#+id/buttonDivide"
android:layout_row="2"
android:layout_column="3"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#drawable/button2"
android:textSize="20sp"
android:text="/" />
<Button
android:id="#+id/buttonSeven"
android:layout_column="0"
android:layout_row="3"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="7"/>
<Button
android:id="#+id/buttonEight"
android:layout_column="1"
android:layout_row="3"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="8"/>
<Button
android:id="#+id/buttonNine"
android:layout_row="3"
android:layout_column="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#drawable/button1"
android:textSize="20sp"
android:text="9" />
<Button
android:id="#+id/buttonMultiply"
android:layout_row="3"
android:layout_column="3"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#drawable/button2"
android:textSize="20sp"
android:text="X" />
</GridLayout>
What am I doing wrong?
android:layout_rowWeight="1"
android:layout_columnWeight="1"
this attribute is only used in API21 and higher. you should use supportv7
GridLayout instead.
add this
compile 'com.android.support:gridlayout-v7:26.0.0-alpha1'
in your module's build.gradle.
then change you xml like this.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
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"
tools:context="com.example.pvtboromeo.test.MainActivity"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/editText"
android:background="#android:color/black"
android:textColor="#android:color/white"
app:layout_row="0"
app:layout_column="0"
app:layout_columnSpan="4"
app:layout_rowSpan="2"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:enabled="false"
android:gravity="bottom|right"
android:paddingRight="15sp"
android:paddingBottom="15sp"
android:textAlignment="gravity"
android:textSize="40sp"
android:text="TEST" />
<Button
android:id="#+id/buttonC"
app:layout_column="0"
app:layout_row="2"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="C"/>
<Button
android:id="#+id/buttonNegative"
app:layout_column="1"
app:layout_row="2"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="+/-"/>
<Button
android:id="#+id/buttonPercent"
app:layout_row="2"
app:layout_column="2"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="%" />
<Button
android:id="#+id/buttonDivide"
app:layout_row="2"
app:layout_column="3"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="/" />
<Button
android:id="#+id/buttonSeven"
app:layout_column="0"
app:layout_row="3"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="7"/>
<Button
android:id="#+id/buttonEight"
app:layout_column="1"
app:layout_row="3"
app:layout_columnWeight="1"
app:layout_rowWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="8"/>
<Button
android:id="#+id/buttonNine"
app:layout_row="3"
app:layout_column="2"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="9" />
<Button
android:id="#+id/buttonMultiply"
app:layout_row="3"
app:layout_column="3"
app:layout_rowWeight="1"
app:layout_columnWeight="1"
android:background="#color/colorPrimary"
android:textSize="20sp"
android:text="X" />
</android.support.v7.widget.GridLayout>
notice, this is android.support.v7.widget.GridLayout not android.widget.GridLayout, and the attribute is
app:layout_rowWeight="1" not android:layout_rowWeight="1"
I suggest you to use a ConstraintLayout. Is the better way to do layouts with a lot of view.
It's the best way to have good performance too (and you need less time to program it).
More neasted view you have, more slowly works your activity.
For a simple layout of a calculator you can try to see my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.moris.calcolatricelayoutconstraint.MainActivity">
<TextView
android:id="#+id/textView24"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="/"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView5"
app:layout_constraintRight_toLeftOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView21" />
<TextView
android:id="#+id/textView25"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="x"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView22" />
<TextView
android:id="#+id/textView26"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="="
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView23" />
<TextView
android:id="#+id/textView21"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="-"
app:layout_constraintBottom_toTopOf="#+id/textView24"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView5"
app:layout_constraintRight_toLeftOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView18" />
<TextView
android:id="#+id/textView22"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="+"
app:layout_constraintBottom_toTopOf="#+id/textView25"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView19" />
<TextView
android:id="#+id/textView23"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="%"
app:layout_constraintBottom_toTopOf="#+id/textView26"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView20" />
<TextView
android:id="#+id/textView18"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="8"
app:layout_constraintBottom_toTopOf="#+id/textView21"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView5"
app:layout_constraintRight_toLeftOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView15" />
<TextView
android:id="#+id/textView19"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="7"
app:layout_constraintBottom_toTopOf="#+id/textView22"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView16" />
<TextView
android:id="#+id/textView20"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="9"
app:layout_constraintBottom_toTopOf="#+id/textView23"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView17" />
<TextView
android:id="#+id/textView15"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="5"
app:layout_constraintBottom_toTopOf="#+id/textView18"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView5"
app:layout_constraintRight_toLeftOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView3" />
<TextView
android:id="#+id/textView16"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="4"
app:layout_constraintBottom_toTopOf="#+id/textView19"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView5" />
<TextView
android:id="#+id/textView17"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="6"
app:layout_constraintBottom_toTopOf="#+id/textView20"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/textView3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6" />
<TextView
android:id="#+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="#+id/textView3"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="6dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="6dp"
android:layout_marginStart="8dp"
android:ems="10"
android:hint="Insert numbers"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="#+id/textView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.0" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="2"
app:layout_constraintBottom_toTopOf="#+id/textView15"
app:layout_constraintLeft_toRightOf="#+id/textView5"
app:layout_constraintRight_toLeftOf="#+id/textView6"
app:layout_constraintTop_toBottomOf="#+id/textView" />
<TextView
android:id="#+id/textView5"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="1"
app:layout_constraintBottom_toTopOf="#+id/textView16"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView" />
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/border"
android:gravity="center"
android:text="3"
app:layout_constraintBottom_toTopOf="#+id/textView17"
app:layout_constraintLeft_toRightOf="#+id/textView3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
To do the border, I've created this xml file call "border", in drawable resource, and use that in the TextView's background:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:color="#color/colorPrimaryDark"
android:width="2dp"/>
<corners
android:radius="5dp"/>
If you want learn more about ConstraintLayout: https://developer.android.com/training/constraint-layout/index.html
In particulary, watch the video 4.
Hello I have made simple calculator app for Android. It all works well.
But my next step was to implement layout for landscape mode. After an hour I've came out with nice layout, everything looks fine... until I run the app on device (Huawei P8 Lite).
This is how it looks in the Designer/Preview:
And here's how it's like running on my device:
I have no idea what might be wrong. I've made a couple of layouts before and didn't have such issue. Does anyone know what might cause the bug?
This is my XML layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8">
<me.grantland.widget.AutofitLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".30"
android:gravity="right"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<EditText
android:id="#+id/textBox1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|bottom|right"
android:maxLines="1"
android:textSize="30dp"
android:textStyle="italic" />
</me.grantland.widget.AutofitLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="0.2">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp">
<Button
android:id="#+id/bracketLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="("
app:layout_constraintLeft_toRightOf="#+id/three"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/plus" />
<Button
android:id="#+id/bracketRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=")"
app:layout_constraintLeft_toRightOf="#+id/bracketLeft"
android:layout_marginLeft="0dp"
app:layout_constraintRight_toLeftOf="#+id/equals"
android:layout_marginRight="8dp"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/minus" />
<Button
android:id="#+id/button27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="^"
app:layout_constraintLeft_toRightOf="#+id/button26"
android:layout_marginLeft="-1dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/bracketRight" />
<Button
android:id="#+id/one"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="1"
android:typeface="normal"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/four" />
<ImageButton
android:id="#+id/backspace"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:src="#drawable/ic_backspace_black_24dp"
app:layout_constraintLeft_toRightOf="#+id/multiple"
android:layout_marginLeft="0dp"
tools:layout_editor_absoluteY="8dp" />
<Button
android:id="#+id/multiple"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_row="0"
android:fontFamily="sans-serif"
android:text="X"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/divide"
android:layout_marginLeft="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="#+id/two"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="2"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/one"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/five" />
<Button
android:id="#+id/three"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="3"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/two"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/six" />
<Button
android:id="#+id/four"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="4"
android:typeface="normal"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/seven" />
<Button
android:id="#+id/six"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="6"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/five"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/nine" />
<Button
android:id="#+id/divide"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="/"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/nine"
android:layout_marginLeft="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="#+id/clear"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="C"
android:typeface="normal"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toTopOf="#+id/equals"
app:layout_constraintLeft_toRightOf="#+id/minus"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/backspace"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="#+id/seven"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="7"
android:typeface="normal"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="#+id/eight"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="8"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/seven"
android:layout_marginLeft="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="#+id/five"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="5"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/four"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/eight" />
<Button
android:id="#+id/plus"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="+"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/six"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/divide" />
<Button
android:id="#+id/minus"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="-"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/plus"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/multiple" />
<Button
android:id="#+id/nine"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="9"
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/eight"
android:layout_marginLeft="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp" />
<Button
android:id="#+id/dot"
style="#style/appButtonMaterial_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="."
android:typeface="normal"
app:layout_constraintLeft_toRightOf="#+id/zero"
android:layout_marginLeft="-1dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/three" />
<Button
android:id="#+id/equals"
style="#style/appButtonMaterial_land"
android:layout_height="97dp"
android:fontFamily="sans-serif"
android:text="="
android:typeface="normal"
tools:layout_editor_absoluteY="103dp"
app:layout_constraintLeft_toRightOf="#+id/button27"
android:layout_marginLeft="0dp"
app:layout_constraintDimensionRatio="w,1:1" />
<Button
android:id="#+id/zero"
style="#style/appButtonMaterial_land"
android:layout_width="176dp"
android:fontFamily="sans-serif"
android:text="0"
android:typeface="normal"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_height="49dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/two" />
<Button
android:id="#+id/button26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-1dp"
android:text="%"
app:layout_constraintLeft_toRightOf="#+id/dot"
android:layout_marginTop="0dp"
app:layout_constraintTop_toBottomOf="#+id/bracketLeft" />
</android.support.constraint.ConstraintLayout>
</RelativeLayout>
</LinearLayout>
I want to design custom keyboard , but I find problem with view
another view
my xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/voucherrelative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/vouchertxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="Enter Voucher Code"
android:textSize="25sp" />
<LinearLayout
android:id="#+id/codeLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/vouchertxt"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:weightSum="3">
<EditText
android:id="#+id/code1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="number"
android:maxLength="3"
android:nextFocusUp="#+id/code2"
android:singleLine="true"
android:textCursorDrawable="#drawable/black_cursor"
android:textSize="25dp" />
<EditText
android:id="#+id/code2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:gravity="center"
android:imeOptions="actionNext"
android:inputType="number"
android:maxLength="3"
android:nextFocusDown="#+id/code1"
android:nextFocusUp="#+id/code3"
android:textCursorDrawable="#drawable/black_cursor"
android:textSize="25dp" />
<EditText
android:id="#+id/code3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:maxLength="3"
android:nextFocusDown="#+id/code2"
android:textCursorDrawable="#drawable/black_cursor"
android:textSize="25dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/check_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/codeLinear"
android:orientation="horizontal">
<Button
android:id="#+id/scanqr"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="2"
android:background="#drawable/roundedwhite"
android:text="Scan "
android:textColor="#191919" />
<Button
android:id="#+id/buttoncheck"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="2"
android:background="#drawable/roundedbutton"
android:text="Check"
android:textColor="#ffffff"
/>
</LinearLayout>
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/check_linear"
app:alignmentMode="alignBounds"
app:columnCount="4"
app:columnOrderPreserved="false"
app:orientation="horizontal"
app:rowCount="5"
app:useDefaultMargins="false">
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/roundedbutton"
android:text="7"
android:textColor="#ffffff"
app:layout_row="1" />
<Button
android:id="#+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/roundedbutton"
android:text="8"
android:textColor="#ffffff"
app:layout_row="1" />
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/roundedbutton"
android:text="9"
android:textColor="#ffffff"
app:layout_column="2"
app:layout_row="1" />
<Button
android:id="#+id/buttonDel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#drawable/roundedwhite"
android:text="Del"
android:textColor="#191919"
app:layout_column="3"
app:layout_row="1"
app:layout_rowSpan="2"
app:layout_gravity="fill_vertical"
/>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="#drawable/roundedbutton"
android:text="4"
android:textColor="#ffffff"
app:layout_column="0"
app:layout_row="2" />
<Button
android:id="#+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="5"
android:textColor="#ffffff"
app:layout_column="1"
app:layout_row="2" />
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="6"
android:textColor="#ffffff"
app:layout_column="2"
app:layout_row="2" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:background="#drawable/roundedbutton"
android:text="1"
android:textColor="#ffffff"
app:layout_column="0"
app:layout_row="3" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="2"
android:textColor="#ffffff"
app:layout_column="1"
app:layout_row="3" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="3"
android:textColor="#ffffff"
app:layout_column="2"
app:layout_row="3" />
<Button
android:id="#+id/buttonclear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedwhite"
android:text="Clear"
android:textColor="#191919"
app:layout_gravity="fill_vertical"
app:layout_row="3"
app:layout_rowSpan="2"/>
<Button
android:id="#+id/button0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:layout_weight="2"
android:background="#drawable/roundedbutton"
android:text="0"
android:textColor="#ffffff"
app:layout_column="0"
app:layout_columnSpan="2"
app:layout_columnWeight="2"
app:layout_gravity="fill_horizontal"
app:layout_row="4" />
<Button
android:id="#+id/btn55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/roundedbutton"
android:text="."
android:textColor="#ffffff"
app:layout_column="2"
app:layout_row="4" />
</android.support.v7.widget.GridLayout>
</RelativeLayout>
any suggestion how to make this keyboard look better