isDisplayed() not working with Appium 1.6.1

Hi…I am trying to automate a scenario where I have to scroll down until 1 element is displayed but isDisplayed method is not working.

Platform- Both iOS and android
Java- 1.8
Appium 1.6.1

share the logs.
with logs it will be easy to understand the issue

	while(flag)
	{
		try{
			//element.isDisplayed();
			
			String fla=element.getAttribute("visible");
			if(fla.equals("true"))
			{
				flag=false;

			}else {
				flag=true;
				swipe_ins(driver, "up");

			}

		}catch(Exception e)
		{
			swipe_ins(driver, "up");
			count++;
			if(count==5)
			{
				failNew(driver, "verify if element is displayed in screen", "", "element is not displayed in screen", ExtentTestManager.getTest());
				break;
			}

		}

	}

I was trying with element.isdsplayed but it never returned true and loop never ended…now m trying with getAttribute of visible but element’s visibility is always false…even in UIAutomator