Can't I put all my buttons on the screen? Is the last line and a half buttons disconnected from the screen? The final layout looks a little different. I created custom buttons, and for most buttons there are additional functions, but I simplified the code to eliminate all possible errors that are not directly related to my problem. I would like the buttons to fill and stay on the screen (I would post a photo of my layout, but my reputation is too low)
RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
<ImageView
android:id="@+id/sample"
android:layout_below="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/contentDescriptionImageView"
android:scaleType="centerInside"
android:src="@drawable/sample" />
<Button
android:id="@+id/b11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/sample"
android:layout_margin="0dp"
android:text="@string/b11" />
//...buttons
<Button
android:id="@+id/b95"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/b85"
android:layout_margin="0dp"
android:layout_toRightOf="@+id/b94"
android:text="@string/b95" />
</RelativeLayout>
LinearLayout (LinearLayout + GridLayout)
<?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:grid="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutH1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1.0"
android:orientation="vertical" >
<EditText
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
<ImageView
android:id="@+id/sample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/contentDescriptionImageView"
android:scaleType="centerInside"
android:src="@drawable/sample" />
</LinearLayout>
<GridLayout
android:id="@+id/GridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="5"
android:rowCount="9"
android:useDefaultMargins="false" >
<Button
android:id="@+id/b11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b11" />
//...buttons are the same, I just erased the following RelativeLayout attributes:
-android:layout_below
-android:layout_toRightOf
-android:layout_alignParentBottom
<Button
android:id="@+id/b95"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b95" />
</GridLayout>
</LinearLayout>
http://postimg.org/image/wvcl7rfer/eeef02dd/
Here's a solution that worked for me (I haven't tried GridView or TableLayout) This is one from BrOtherSOul. Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
<ImageView
android:id="@+id/sample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/contentDescriptionImageView"
android:scaleType="centerInside"
android:src="@drawable/sample" />
<LinearLayout
android:id="@+id/linearLayoutH3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b11" />
<Button
android:id="@+id/b12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b12" />
<Button
android:id="@+id/b13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b13" />
<Button
android:id="@+id/b14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b14" />
<Button
android:id="@+id/b15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b15" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b21" />
<Button
android:id="@+id/b22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b22" />
<Button
android:id="@+id/b23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b23" />
<Button
android:id="@+id/b24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b24" />
<Button
android:id="@+id/b25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b25" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH7"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b31" />
<Button
android:id="@+id/b32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b32" />
<Button
android:id="@+id/b33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b33" />
<Button
android:id="@+id/b34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b34" />
<Button
android:id="@+id/b35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b35" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH9"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b41" />
<Button
android:id="@+id/b42"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b42" />
<Button
android:id="@+id/b43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b43" />
<Button
android:id="@+id/b44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b44" />
<Button
android:id="@+id/b45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b45" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH11"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b51"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b51" />
<Button
android:id="@+id/b52"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b52" />
<Button
android:id="@+id/b53"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b53" />
<Button
android:id="@+id/b54"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b54" />
<Button
android:id="@+id/b55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b55" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH13"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b61"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b61" />
<Button
android:id="@+id/b62"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b62" />
<Button
android:id="@+id/b63"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b63" />
<Button
android:id="@+id/b64"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b64" />
<Button
android:id="@+id/b65"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b65" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH15"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b71"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b71" />
<Button
android:id="@+id/b72"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b72" />
<Button
android:id="@+id/b73"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b73" />
<Button
android:id="@+id/b74"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b74" />
<Button
android:id="@+id/b75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b75" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH17"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b81"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b81" />
<Button
android:id="@+id/b82"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b82" />
<Button
android:id="@+id/b83"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b83" />
<Button
android:id="@+id/b84"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b84" />
<Button
android:id="@+id/b85"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b85" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayoutH19"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="@+id/b91"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b91" />
<Button
android:id="@+id/b92"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b92" />
<Button
android:id="@+id/b93"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b93" />
<Button
android:id="@+id/b94"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b94" />
<Button
android:id="@+id/b95"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:text="@string/b95" />
</LinearLayout>
</LinearLayout>
http://postimg.org/image/ltromjjpp/5ad91d61/