-1

I asked a similar question last night but I don't think I asked the right question. I'm working on a tip calculator and when I click on one of the EditText fields to enter a number and the keyboard comes up the entire app shifts up and the background resizes. It looks like this

I don't want the background to resize and I don't want everything to shift up, I just want everything to be scrollable except for the ad when the keyboard comes up. Any help would be greatly appreciated.

Here's my activity_main

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.tipcalculator.app.MainActivity"
    android:orientation="vertical">

    <com.google.android.gms.ads.AdView android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="adid"
        ads:adSize="BANNER"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true"
        android:layout_below="@+id/adView">

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number|numberDecimal"
        android:ems="10"
        android:id="@+id/tipTxt"
        android:editable="true"
        android:clickable="true"
        android:hint="Other"
        android:layout_alignBottom="@+id/tipOthr"
        android:layout_toRightOf="@+id/tipOthr"
        android:enabled="false" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number|numberDecimal"
        android:ems="10"
        android:id="@+id/priceTxt"
        android:editable="true"
        android:clickable="true"
        android:hint="Price"
        android:enabled="true"
        android:layout_above="@+id/splitInTxt"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/splitTxt"
        android:layout_marginBottom="22dp"
        android:editable="false"
        android:clickable="false"
        android:layout_alignParentBottom="true"
        android:layout_alignLeft="@+id/totalTxt"
        android:layout_alignStart="@+id/totalTxt"
        android:gravity="center_vertical"
        android:text="$0.00"
        android:textAlignment="center" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Calculate Tip"
        android:id="@+id/calcBtn"
        android:enabled="false"
        android:layout_marginBottom="29dp"
        android:clickable="true"
        android:gravity="center_vertical"
        android:layout_above="@+id/totalTxt"
        android:layout_centerHorizontal="true" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/totalTxt"
        android:editable="false"
        android:clickable="false"
        android:gravity="center_vertical"
        android:text="$0.00"
        android:textAlignment="center"
        android:layout_alignBottom="@+id/textView2"
        android:layout_alignLeft="@+id/tipOutTxt "
        android:layout_alignStart="@+id/tipOutTxt " />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="10%"
        android:id="@+id/tipTen"
        android:checked="false"
        android:clickable="true"
        android:enabled="true"
        android:layout_above="@+id/tipFtn"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="15%"
        android:id="@+id/tipFtn"
        android:checked="false"
        android:clickable="true"
        android:enabled="true"
        android:layout_above="@+id/tipTnty"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="20%"
        android:id="@+id/tipTnty"
        android:checked="false"
        android:clickable="true"
        android:enabled="true"
        android:layout_above="@+id/tipTxt"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tipOthr"
        android:checked="false"
        android:layout_above="@+id/calcBtn"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="29dp"
        android:clickable="true"
        android:enabled="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Total"
        android:id="@+id/textView2"
        android:layout_above="@+id/splitTxt"
        android:layout_alignRight="@+id/textView3"
        android:layout_alignEnd="@+id/textView3" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Split"
        android:id="@+id/textView3"
        android:layout_alignBottom="@+id/splitTxt"
        android:layout_alignRight="@+id/textView5"
        android:layout_alignEnd="@+id/textView5" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Split"
        android:id="@+id/textView"
        android:longClickable="false"
        android:singleLine="true"
        android:layout_above="@+id/tipTen"
        android:layout_toLeftOf="@+id/minusBtn" />


    <EditText
        android:layout_width="76dp"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:ems="10"
        android:id="@+id/splitInTxt"
        android:text="1"
        android:enabled="true"
        android:editable="true"
        android:gravity="center|right"
        android:layout_above="@+id/tipTen"
        android:layout_centerHorizontal="true" />

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="+"
        android:id="@+id/plusBtn"
        android:enabled="true"
        android:clickable="true"
        android:layout_alignBottom="@+id/splitInTxt"
        android:layout_alignRight="@+id/tipTxt"
        android:layout_alignEnd="@+id/tipTxt" />

    <Button
        style="?android:attr/buttonStyleSmall"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="-"
        android:id="@+id/minusBtn"
        android:clickable="true"
        android:enabled="true"
        android:layout_alignBottom="@+id/splitInTxt"
        android:layout_toLeftOf="@+id/splitInTxt" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/tipOutTxt "
        android:editable="false"
        android:clickable="false"
        android:gravity="center_vertical"
        android:text="$0.00"
        android:textAlignment="center"
        android:layout_alignBottom="@+id/textView5"
        android:layout_centerHorizontal="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Tip"
        android:id="@+id/textView5"
        android:layout_above="@+id/totalTxt"
        android:layout_toRightOf="@+id/tipOthr" />
    </RelativeLayout>
    </LinearLayout>
    </ScrollView>
</RelativeLayout>

and my AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tipcalculator.app" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name="com.example.tipcalculator.app.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.android.gms.ads.AdActivity"
            android:windowSoftInputMode="adjustPan"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
323go
  • 14,143
  • 6
  • 33
  • 41

3 Answers3

1

Try this; maybe it is use full. Adjust the manifest file Look at this MOVE UP VIEW

<activity
  android:windowSoftInputMode="adjustResize"              
  android:name=".youractivity" android:label="@string/app_name" >
Community
  • 1
  • 1
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98
0

You can just add the scrollbars in the XML file using properties. You just check which way you want the scroll to lay on the screen.

Shon
  • 5
  • 4
  • I'm not sure I follow, this is my first android app so I don't get what you mean. I have a scrollview in my xml right now – user3682017 May 29 '14 at 04:45
0

Use this

<activity android:name="com.google.android.gms.ads.AdActivity"
 android:windowSoftInputMode="adjustResize|stateHidden"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Sulabh Gajjar
  • 496
  • 4
  • 16