Question

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="1"
    android:rowCount="3"
    android:verticalSpacing="1px" >

    <ImageButton
        android:id="@+id/AlertBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_gravity="fill_horizontal"
        android:layout_row="1"
        android:src="@drawable/mylocation" />

    <ImageButton
        android:id="@+id/myLocationBtn"
        android:layout_width="306dp"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_gravity="fill_horizontal"
        android:layout_row="2"
        android:src="@drawable/proximity" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_column="0"
        android:layout_gravity="fill_horizontal"
        android:layout_row="0"
        android:src="@drawable/title" />

</GridLayout>

I want to make these 3 items completely fill the scren and if is possible no white space between each item. I have been playing with the gridlayout but since it's new and I don't have much experience in programming, I can't get what I want.

Any help would be appreciated.

Was it helpful?

Solution 2

Try the modified xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="1"
android:orientation="vertical" >

<ImageButton
    android:id="@+id/AlertBtn"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="fill_horizontal"
    android:layout_weight="1"
    android:src="@drawable/mylocation" />

<ImageButton
    android:id="@+id/myLocationBtn"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="fill_horizontal"
    android:layout_weight="1"
    android:src="@drawable/proximity" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="fill_horizontal"
    android:layout_weight="1"
    android:src="@drawable/title" />

</LinearLayout>

let me know.. what do you think

If you want to remove the button background add this to the ImageButton

android:background="@null"

after removing the background for the button set you own custom background color or image in the parent linearlayout like this

android:background="#DCDCDC"

OTHER TIPS

Try with LinearLayout it's easy..

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/AlertBtn"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@drawable/mylocation" />

    <ImageButton
        android:id="@+id/myLocationBtn"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@drawable/proximity" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:src="@drawable/title" />

</LinearLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top