Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9271] Android: ScrollView automatically scrolls when anyDensity="false"

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-06-21T16:29:01.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sn/a
ComponentsAndroid
LabelsSupportTeam, api
ReporterEduardo Gomez
AssigneePing Wang
Created2012-05-24T19:30:49.000+0000
Updated2017-03-22T21:03:33.000+0000

Description

Problem

ScrollView automatically scrolls when anyDensity="false"

Expected behavior

ScrollView do not scrolls

Tested on

Device: LG Ally 2.2 Android 2.2 WVGA emulator

tiapp.xml (having anyDensity="false")

    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:installLocation="auto">
            <supports-screens android:anyDensity="false"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.CAMERA"/>
            <uses-permission android:name="android.permission.FLASHLIGHT"/>
        </manifest>
    </android>

Steps to reproduce

1. Run app.js below 2. Notice the screen is cut off at the very beginning

Repro sequence

var win = Titanium.UI.createWindow({
	//windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN
	backgroundColor: 'gray'
});
 
win.orientationModes = [
    Titanium.UI.PORTRAIT,
    Titanium.UI.UPSIDE_PORTRAIT,
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT
]; 
 
var scrolly = Titanium.UI.createScrollView({
    contentHeight:'auto'
});
win.add(scrolly);

var view = Ti.UI.createView({
	top: 15,
	height: 100,
	width: '90%',
	backgroundColor: 'red'
});
scrolly.add(view);


var data = [];
for(i=0; i<5; i++){
	data[i] = Ti.UI.createTableViewRow({
		title: 'Row: '+ i
	});
}
var table = Ti.UI.createTableView({
	data: data,
	top: 145,
	height: '400',
	width: '90%',
	backgroundColor: 'blue'
	
});
scrolly.add(table);

var view = Ti.UI.createView({
	top: 700,
	height: 100,
	width: '90%',
	backgroundColor: 'yellow'
});
scrolly.add(view);
 
win.open();

Stack trace Actual device OS 2.2

05-24 19:46:04.872: I/ActivityManager(1347): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.appc.test/._1testyActivity }
05-24 19:46:04.902: I/ActivityManager(1347): Start proc com.appc.test for activity com.appc.test/._1testyActivity: pid=27017 uid=10071 gids={1015, 1006, 3003}
05-24 19:46:05.022: I/ActivityManager(1347): Process com.vzw.vvm.androidclient (pid 26660) has died.
05-24 19:46:05.042: I/ActivityManager(1347): Process com.svox.pico (pid 26200) has died.
05-24 19:46:05.172: I/ActivityManager(1347): Process android.process.media (pid 26673) has died.
05-24 19:46:05.342: I/TiApplication(27017): (main) [0,0] checkpoint, app created.
05-24 19:46:05.562: I/TiApplication(27017): (main) [232,232] Titanium 2.0.1 (2012/04/12 16:36 999c68a)
05-24 19:46:05.902: I/TiApplication(27017): (main) [340,572] Titanium Javascript runtime: v8
05-24 19:46:05.952: I/TiRootActivity(27017): (main) [0,0] checkpoint, on root activity create, savedInstanceState: Bundle[mParcelledData.dataSize=1148]
05-24 19:46:08.292: E/TiApplication(27017): (KrollRuntimeThread) [2341,2341] APP PROXY: ti.modules.titanium.app.AppModule@44a2a210
05-24 19:46:08.632: W/V8Object(27017): Runtime disposed, cannot set property 'userAgent'
05-24 19:46:08.892: W/TiUIScrollView(27017): (main) [600,2941] Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction.
05-24 19:46:08.922: I/ActivityManager(1347): Process com.google.android.apps.uploader (pid 26681) has died.
05-24 19:46:09.152: I/TiRootActivity(27017): (main) [0,0] checkpoint, on root activity resume. activity = com.appc.test._1testyActivity@44a0eef0
05-24 19:46:09.922: I/ActivityManager(1347): Displayed activity com.appc.test/._1testyActivity: 5039 ms (total 5039 ms)
05-24 19:46:10.482: I/ActivityManager(1347): Process com.facebook.katana (pid 26030) has died.

Attachments

FileDateSize
ActualDevice_Scrolls.jpg2012-05-24T19:30:49.000+00001115852
WVGA_Emulator.jpg2012-05-24T19:30:49.000+000076720

Comments

  1. Ping Wang 2012-06-21

    In Android, a view goes down the view chain (parent->child) to request focus. First view which is "focusable" wins and becomes focused. In the test case attached above, the table view gains the focus so the scrollview automatically scrolls in order to show the table view. This is a native Android behavior. We can see this happens with and without anyDensity='false' using the test case below.
       var win = Titanium.UI.createWindow({
           //windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN
           backgroundColor: 'gray'
       });
         
       win.orientationModes = [
           Titanium.UI.PORTRAIT,
           Titanium.UI.UPSIDE_PORTRAIT,
           Titanium.UI.LANDSCAPE_LEFT,
           Titanium.UI.LANDSCAPE_RIGHT
       ]; 
         
       var offset = 300;
        
       var scrolly = Titanium.UI.createScrollView({
           contentHeight:'auto'
       });
       win.add(scrolly);
        
       var view = Ti.UI.createView({
           top: 15,
           height: 100 + offset,
           width: '90%',
           backgroundColor: 'red'
       });
       scrolly.add(view);
        
        
       var data = [];
       for(i=0; i<5; i++){
           data[i] = Ti.UI.createTableViewRow({
               title: 'Row: '+ i
           });
       }
       var table = Ti.UI.createTableView({
           data: data,
           top: 145 + offset,
           height: '500',
           width: '90%',
           backgroundColor: 'blue'
            
       });
       scrolly.add(table);
        
       var view = Ti.UI.createView({
           top: 800 + offset,
           height: 100,
           width: '90%',
           backgroundColor: 'yellow'
       });
       scrolly.add(view);
         
       win.open();
       
    If we change the table view to a plain view, scrollview won't automatically scroll. BTW, mixing scrollview and tableview is strongly discouraged because scroll events for the two objects can be mixed up and wrongly handled.
  2. Lee Morris 2017-03-22

    Closing ticket as invalid with reference to the above comments.

JSON Source