I am aware that I can't use ListView
inside ScrollView
, because ScrollView
gets the focus in that case and ListView
becomes non-scrollable. But I have a program that enables the scrolling of both ListView
and ScrollView
.(followed the great answer by Mr. Arshu)
Structure of my activity_main.xml
<RelativeLayout >
<ScrollView
android:fillViewport="true" >
<LinearLayout >
<TextView />
<TextView />
<LinearLayout >
<Button
android:id="@+id/button1" />
<Button
android:id="@+id/button2" />
</LinearLayout>
<RelativeLayout
android:visibility="gone" >
<WebView />
<ImageView />
</RelativeLayout>
<LinearLayout >
<TextView />
<TextView />
<TextView />
<TextView />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_alignParentBottom="true" >
<ImageView />
<Button />
<ListView
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
This works perfectly when it is in portrait mode.Each View
in Activity
has its own purpose.
But I have two issues in Landscape
mode.
[I can't use activity-land
as because I'm playing video in WebView
]
- The
ListView
is visible when I click the button.
In portrait
mode it display all items(ex: 10). When I change the mode to landscape the ListView
doesn't scroll completely and it displays only 5 or 5 1/2 items.
2.WebView
visibility is enabled on Button
click.
If suppose I enable the webview in portrait mode and video starts playing, and in between if I change the mode to Landscape
then the WebView disappears but video is not stopped. I can hear the video.
I've tried to control the view
by using savedInstanceState
.
Code snippet:
button1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if(savedInstanceState==null)
{
String uriPath = "http://player.vimeo.com/***/****";
Layout.setVisibility(View.VISIBLE);
myWebView.setWebViewClient(new WebViewClient());
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl(uriPath);
}else {
Layout.setVisibility(View.VISIBLE);
myWebView.restoreState(savedInstanceState);
}
}
});
Images of ListView
:
In portrait:
In landscape:
How to solve these two issues.
Kindly help.
Thank you.