baron dune
baron dune

Reputation: 367

My imageButton keeps overlapping my textview that I want at the bottom of the screen

For some reason my image button keeps overlapping. When i used the Scroll view at the top it worked correctly and everything was fine, but I dont want to scroll down to see how many times i clicked. I just want the text view at the bottom of the screen without the image button overlapping it,

What am I doing wrong? this is me trying new things

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


    <LinearLayout
      android:id="@+id/LinearLayout01"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical">

    <!-- Stretching frame layout using weights will bring it to the bottom -->


    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/pushme"
    android:textSize="21sp"
    android:gravity="center_horizontal|center_vertical"
    android:textColor="#ff0005"
    android:background="#ff99ff"

    />



    <Button
    android:id="@+id/button"
    android:scaleType="fitCenter"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/push"


    />


<FrameLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_gravity="bottom"
    android:layout_weight="1" 
    android:layout_below="@+id/numClicked"
    >

    <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:padding="8dip"
         android:text="@string/numClicked"
         android:background="#ffffffff"
         android:textColor="#ff127223"

         />

    </FrameLayout>



    </LinearLayout>

now this is me with it working using scroll view, But I dont want scroll view

    <?xml version="1.0" encoding="utf-8"?>
<ScrollView
      android:id="@+id/LinearLayout01"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical">
<LinearLayout
      android:id="@+id/LinearLayout01"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical">

    <!-- Stretching frame layout using weights will bring it to the bottom -->


    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/pushme"
    android:textSize="21sp"
    android:gravity="center_horizontal|center_vertical"
    android:textColor="#ff0005"
    android:background="#ff99ff"

    />



    <Button
     android:id="@+id/button"
     android:scaleType="fitCenter"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:background="@drawable/push"


 />


<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_gravity="bottom"
    android:layout_weight="1" 

    >

    <TextView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:padding="8dip"
         android:text="@string/numClicked"
         android:background="#ffffffff"
         android:textColor="#ff127223"

         />

Upvotes: 0

Views: 755

Answers (3)

AAnkit
AAnkit

Reputation: 27549

IF i am getting it right?? you have button there.. and u are setting background image.. if it is!! then add below button tag in place of your button tag in your layout.. all the best

<Button
android:id="@+id/button"
android:scaleType="fitCenter"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_marginBottom="10dp"
android:background="@drawable/push"


/>

Upvotes: 0

Padma Kumar
Padma Kumar

Reputation: 20041

//I am not getting your problem?

can you try this once is this will solve you problem.

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

        <!-- Stretching frame layout using weights will bring it to the bottom -->

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ff99ff"
            android:gravity="center_horizontal|center_vertical"
            android:text="pushme"
            android:textColor="#ff0005"
            android:textSize="21sp" />

        <ImageView
            android:id="@+id/button"
                android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/apps_icon"
            android:layout_weight="1"
            android:scaleType="center" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#ffffffff"
                android:padding="8dip"
                android:text="numClicked"
                android:textColor="#ff127223" />
        </LinearLayout>
    </LinearLayout>

Upvotes: 0

Bill Gary
Bill Gary

Reputation: 3005

Try this, I had to change some stuff to see it on my emulator, but you can get the gist of it.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout android:layout_width="fill_parent"
    android:orientation="vertical" android:layout_above="@+id/numClicked"
    android:layout_height="fill_parent">

    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="pushme"
        android:textSize="21sp" android:gravity="center_horizontal|center_vertical"
        android:textColor="#ff0005" android:background="#ff99ff" />

    <ImageButton android:src="@drawable/push"
        android:layout_width="fill_parent" android:id="@+id/button"
        android:layout_height="wrap_content" android:layout_gravity="center" />

</LinearLayout>

<TextView android:layout_width="fill_parent" android:id="@+id/numClicked"
    android:layout_height="wrap_content" android:padding="8dip"
    android:text="numClicked" android:layout_alignParentBottom="true" />

</RelativeLayout>

Upvotes: 1

Related Questions