In my app I have a bottom bar which can have many tabs that i can scroll to them.
in other devices other than the Galaxy S2 and S3 the scroll work great but in Samsung S2 and S3 the scroll doesn't work and so some tabs cannot be reached (see figure).
here's my code for the bottom bar (in blue in the picture) :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/svContainerParent"
android:layout_width="match_parent"
android:layout_height="#dimen/height_tab_fragment_bottom"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/svContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/LanguageContainer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:clickable="true"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<ImageView
android:id="#+id/FlagLanguage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="5dp"
android:src="#drawable/english_r" />
</LinearLayout>
<LinearLayout
android:id="#+id/svHolder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center" >
<HorizontalScrollView
android:id="#+id/scrollViewTabs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center" >
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/command"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp" >
<RelativeLayout
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:gravity="center" >
<ImageView
android:id="#+id/cartImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</RelativeLayout>
<LinearLayout
android:id="#+id/textCommand"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:padding="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/cartName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/cart_name"
android:textSize="12sp" />
<TextView
android:id="#+id/cartPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="0.00 €"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
so is this a bug in the galaxy? or is it something wrong i'm doing ?(but why it works on all other devices )
here's the link of the app on the Play Store if someone wish to look this problem.
<LinearLayout
android:id="#+id/svHolder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center" >
<HorizontalScrollView
android:id="#+id/scrollViewTabs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center" >
</HorizontalScrollView>
</LinearLayout>
try to remove the linear layout and keep the HorizontalScrollView
Some things weird on your layout:
1) Why do you have two nested horizontal LinearLayouts ? (svContainerParent and svContainer)
Whatever you are trying to do, you can do it with only one.
2) Remove android:gravity="center" from the RelativeLayout. It does not do anything there.
3) Remove the first LinearLayout wrapping your HorizontalScrollView. Put the necessary parameters on the HorizontalScrollView itself instead.
4) And finally, why do you have that RelativeLayout wrapping your ImageView? You would only use a RelativeLayout if you want your view to go on top (or behind) another view (which does not seem to be the case on your screenshots).
I assume one of those cases is causing the problem of not scrolling on some devices. Let me know if it helps!
Related
I'm trying to build a RelativeLayout which distributes excess space between its children, much as shown here:
I've figured out how to center the red widget inside the blue one, but what I also want to do is distribute any excess vertical space evenly above, below, and between the blue and olive widgets. Currently, everything is bunched up at the top.
My XML looks roughly like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
>
<ImageButton android:id="#+id/blue_button"
android:src="#drawable/blue_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentTop="true"
/>
<ImageView
android:id="#+id/red_box"
android:src="#drawable/red_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/blue_button"
android:layout_marginLeft="10dp"
android:layout_alignTop="#id/blue_button"
android:layout_alignBottom="#id/blue_button"
/>
<ImageButton
android:id="#+id/green_button"
android:src="#drawable/green_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/blue_button"
android:layout_weight="1"
/>
</RelativeLayout>
First, you are using layout_weight with RelativeLayout parent. It's useless because layout_weight works only with LinearLayout parent.
Actually I didn't understand your question (an image of wanted layout would be good) but I guess this will work for you:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
>
<RelativeLayout
android:id="#+id/blueAndRedWrapperLay"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<ImageButton android:id="#+id/blue_button"
android:src="#00CCFF"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_weight="1"
android:layout_centerInParent="true" />
<ImageView
android:id="#+id/red_box"
android:src="#ff0000"
android:layout_width="100dp"
android:layout_height="70dp"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/greenWrapperLay"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<ImageButton
android:id="#+id/green_button"
android:src="#669900"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
/>
</RelativeLayout>
</LinearLayout>
I haven't been able to find a similar problem to the one I'm having on StackOverflow - basically, I have a simple XML layout with a vertical LinerLayout which uses layout_weight to make a 10/50/40 split, which is what I want (as seen below):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".1"
android:text="#string/title"
android:textColor="#color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:orientation="vertical"
android:background="#color/green">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<ImageView
android:id="#+id/preview_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/level_preview_back"
android:focusable="false" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".4"
android:text="#string/title"
android:textColor="#color/black"
android:textStyle="bold" />
</LinearLayout>
BUT - I want the HorizontalScrollView and the ImageView to be overlayed (i.e. take up the exact same space on on top of the other), so I insert a RelativeLayout as such:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".1"
android:text="#string/title"
android:textColor="#color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:orientation="vertical"
android:background="#color/green">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<ImageView
android:id="#+id/preview_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/level_preview_back"
android:focusable="false" />
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".4"
android:text="#string/title"
android:textColor="#color/black"
android:textStyle="bold" />
</LinearLayout>
But when I do this, the layout_weight (10/50/40 split) breaks and suddently the LinearLayout that now contains the RelativeLayout takes up virtually all the screen in the previews.
Anyone experienced this problem or know a good workaround? I've also tried replacing the LinearLayout with the RelativeLayout directly and I have the same problem.
EDIT: Looking further into this issue, there seems to be more to it. As I commented below, I was able to get around the problem by wrapping LinearLayouts around the TextViews, though I'm not sure why that worked. Updating my SDK and plugin didn't help (though I did need to do it....)
Moving further along with my task, I hit a second problem - I was implementing a second version of the overlapped ScrollView & ImageView (which were done with a FrameLayout as suggested by Karsten) but the layout_weight problems began anew.
Testing various arrangements, it seems that the issue is very much related to the image I'm using, which is quite large in resolution. Replacing them with a smaller image corrects the issues - it looks like using large images in either ImageViews or as backgrounds to LinearLayouts tends to ruin the layouts for the entire screen.
EDIT #2: I've actually loaded the XML on to two different devices and it renders exactly as it should.... This seems to be a bug with the Eclipse XML layout viewer?
(Please excuse the poor XML formatting - the Eclipse Android xml editor is frustrating in that regard...)
The XML you've posted works fine for me in the Eclipse preview. Are you running the latest version of the Android plugin?
Note that you can replace the middle LinearLayout and RelativeLayout with a single FrameLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".1"
android:text="string/title"
android:textStyle="bold" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".5"
android:background="#00ff00" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<ImageView
android:id="#+id/preview_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:focusable="false" />
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".4"
android:text="string/title2"
android:textStyle="bold" />
</LinearLayout>
I found a little difficult to force layout (that is inside a SrollView) to be on the bottom of the screen.
Well, it would be easy if I detached this Bottom layout off the ScrollView and create it's own layout on the very bottom using Gravity, but
when someone expands some of the layouts (or rotate to landscape) the app is going to start using the ScrollView. At this moment I want the bottom
part to roll up and down with all the stuff and my "Stretching layout" should be only about 8dp (similar to upper dark-blue line) this time.
Here is my structure: (it is not so complicated how it might seems to be) :)
<ScrollView
android:id="#+id/lt_bcnbldmenu_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/lt_FillScrl"
android:scrollbars="vertical" >
<LinearLayout //HELPER LAYOUT
android:id="#+id/lt_ScrollingPart"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout //only to make some space (upper dark-blue line)
android:id="#+id/lt_Fill1"
android:layout_width="fill_parent"
android:layout_height="6dp"
android:background="#70000000"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout //blue background layout
android:id="#+id/lt_bgLine"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/lt_Fill1"
android:background="#drawable/bg_line"
android:orientation="vertical" >
<LinearLayout //MENU LAYOUT
android:id="#+id/lt_Menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/bg_main"
android:orientation="vertical" >
<LinearLayout //Stuff (first layout)
android:id="#+id/lt_pic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|fill_horizontal"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/img_bcnbldmenu_pic"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#drawable/bg_main_rd"
android:padding="16dp"
android:scaleType="fitXY"
android:src="#drawable/lighthouse" />
<EditText
android:id="#+id/edt_bcnbldmenu_adress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:layout_weight="1"
android:background="#drawable/bg_main_d"
android:ems="10"
android:gravity="start"
android:hint="Beacon Adress..."
android:inputType="textMultiLine"
android:padding="16dp"
android:textColor="#222222"
android:textColorHint="#777777"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout //Stuff (second layout)
android:id="#+id/lt_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg_main_ud"
android:orientation="horizontal" >
<EditText
android:id="#+id/edt_bcnbldmenu_group"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_gravity="left"
android:layout_weight="1"
android:background="#00000000"
android:ems="10"
android:gravity="center"
android:hint="Group..."
android:inputType="textPersonName"
android:minHeight="100dp"
android:textColor="#222222"
android:textColorHint="#777777" />
<Button
android:id="#+id/btn_bcnbldmenu_list"
android:layout_width="68dp"
android:layout_height="fill_parent"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:background="#drawable/btn_list"
android:gravity="center_vertical|center_horizontal"
android:textOff="#string/nothing"
android:textOn="#string/nothing" />
</LinearLayout>
<EditText //Stuff (third layout - actually only a textbox)
android:id="#+id/edt_BcnBldMenu_Description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:ems="10"
android:gravity="top|left"
android:hint="Description..."
android:inputType="textMultiLine"
android:minHeight="100dp"
android:padding="16dp"
android:textColor="#222222"
android:textColorHint="#777777"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout //STRETCHING LAYOUT (lower dark-blue line)
android:id="#+id/lt_Fill2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#70000000"
android:minHeight="32dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout //BOTTOM LAYOUT
android:id="#+id/lt_BottomMenu"
android:layout_width="fill_parent"
android:layout_height="62dp"
android:layout_weight="1"
android:background="#drawable/bg_line"
android:gravity="bottom"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:layout_weight="0"
android:background="#00000000"
android:scaleType="center"
android:src="#drawable/uncheck_press" />
<ImageView //empty image to make some space here
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:src="#00000000" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="100dp"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:layout_weight="0"
android:background="#00000000"
android:scaleType="center"
android:src="#drawable/crane" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I hope there is an easy way to figure this out, because otherwise I will have to do it programmatically somehow which I really want to avoid.
Thanks in advance! I am looking for a solution for several hours.
Add this property to your ScrollView in XML:
android:fillViewport="true"
This will make the "Helper layout" at least as high as the ScrollView in the case if scrolling is not necessary.
The easiest way in my opinion of solving your problem is to check if the helper Linearlayout has less height than the ScrollView.
Also note that the preferred xml syntax is "match_parent" and not "fill_parent", which is technically deprecated.
1. In the XML change layout_height to wrap_content for the helper Linearlayout, also remove layout_gravity and gravity, useless code for this solution. You also add an empty view into the helper LinearLayout. Your XML should look like this:
<ScrollView
android:id="#+id/lt_bcnbldmenu_scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="#+id/lt_FillScrl"
android:scrollbars="vertical" >
<LinearLayout //HELPER LAYOUT
android:id="#+id/lt_ScrollingPart"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/lt_empty"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout //only to make some space (upper dark-blue line)
android:id="#+id/lt_Fill1"
android:layout_width="fill_parent"
android:layout_height="6dp"
android:background="#70000000"
android:orientation="vertical" >
</LinearLayout>
....
2. in the OnCreate(...) method of the respective Activity, add the following:
final ScrollView scrollView = (ScrollView)findViewById(R.id.lt_bcnbldmenu_scroll);
final LinearLayout helperLayout = (LinearLayout)findViewById(R.id.lt_ScrollingPart);
final View emptyView = findViewById(R.id.lt_empty);
// when post(...) is called all View heights have been measured by Android
helperLayout.post(new Runnable() {
#Override
public void run() {
int nHeightDiff = scrollView.getHeight() - helperLayout.getHeight();
// Does the ScrollView have more height than what it contains?
if (nHeightDiff > 0) {
// add padding to compensate for the missing height, you can also set the height directly via LinearLayout.LayoutParams(...)
emptyView.setPadding(0, nHeightDiff, 0, 0);
}
}
});
When I render a large Webview on android 4.1, the webview loads correctly, but also popsout of the layout. Here's an example:
As you can see in the top left corner, there's a white space, that shouldn't be there. If I tap with my finger it, it disappears...
I've tried to invalidate & requestLayout the top level container of this contentView, but it's still happening.
As I said in title, this is only happening in 4.0.4 devices (I know that 4.1 are ok.)
Do you guys know what else could I try?
Thanks.
Edit
That blank rectangle, is somehow over the menubar. Maybe invalidating menu will solve it?
I've tried: this.invalidateOptionsMenu(); and still the same issue.
Edit2:
This is the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/containerTotaApp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="horizontal" >
<View
android:id="#+id/rightshadow"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/contentContainer"
android:background="#drawable/shadow_right" />
<RelativeLayout
android:id="#+id/bgImageSliderContainer"
android:layout_width="700dp"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#000000" >
</RelativeLayout>
<ScrollView
android:id="#+id/scrollView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<LinearLayout
android:id="#+id/containerRightOptional"
android:layout_width="680dp"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:visibility="gone" >
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/navigationContainer"
android:layout_width="320dp"
android:layout_height="match_parent"
android:background="#393939" >
<LinearLayout
android:id="#+id/containerTopMenu"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#drawable/companybg"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/textEntradaMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="COMPANY"
android:textSize="32sp" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/containerTopMenu">
<LinearLayout
android:id="#+id/containerEntradesMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/contentContainer"
android:layout_width="600dp"
android:layout_height="fill_parent"
android:layout_toRightOf="#+id/navigationContainer"
android:background="#ffffff">
<LinearLayout
android:id="#+id/titleContentContainer"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#EBEBEB">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:onClick="toggleMenu"
android:src="#drawable/vista2_cerca" />
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="TextView"
android:textColor="#288BA2"
android:textSize="30sp" />
</LinearLayout>
<View
android:id="#+id/separadortop"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#+id/titleContentContainer"
android:background="#cecece"
android:visibility="gone" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/separadortop"
android:visibility="gone" />
<View
android:id="#+id/separadortop2"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="#+id/spinner1"
android:background="#cecece" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/separadortop2"
android:background="#ffffff" >
<LinearLayout
android:id="#+id/variableContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</RelativeLayout>
The webviews are added dynamically to VariableContent
Granted that I can't pinpoint exactly what the source of your problem is, you can give disabling the hardware acceleration a try:
web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
There are also other "interesting" options that you might try to switch on and off:
webv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
(I know that caching shouldn't be related to your problem, but turning caching off fixed the most curious glitches in my webview, so you probably want to try yourself) and
web.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
No offense to the developers Team, but WebViews on Android are quite a mess, and here are a couple of links to back this statement up:
hardware accelerated webview slide-in animation flickering on ICS
webview goes blank when loading url in android ics
WebView, showing blank in ICS
which might also be useful to you.
Let us know if you find some solution anyway
Hope this helps
Been struggling with this for a while now. I have a layout XML consisting of various LinearLayouts, with separate weighting. The end result looks like this..
Dont mind the colors, its just to see the break points..Anyway, below the Terminal/Origin etc LinearLayout is a ListView which is populated using a custom adapter. The data loads fine, but then the listView "breaks out" of the LinearLayout, and takes up most of the page
(Dont mind the colors, its just to see the break points..)
ie. it flows over the View above and below.
My XML is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="HardcodedText" >
<RelativeLayout
android:id="#+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#FF0000"
android:gravity="right" >
<Button
android:id="#+id/update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:onClick="getFlightInfo"
android:text="Refresh" />
</RelativeLayout>
<LinearLayout
android:id="#+id/table_header"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.4"
android:background="#FFFFFF"
android:weightSum="1" >
<TextView
android:id="#+id/header_cell1"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="#string/cell_1_weight"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="12dp"
android:text="#string/table_header_terminal"
android:textSize="11dp" />
<TextView
android:id="#+id/header_cell2"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="#string/cell_2_weight"
android:gravity="center_vertical"
android:paddingRight="12dp"
android:text="#string/table_header_origin"
android:textSize="11dp" />
<TextView
android:id="#+id/header_cell3"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="#string/cell_3_weight"
android:gravity="center_vertical"
android:paddingRight="12dp"
android:text="#string/table_header_flight"
android:textSize="11dp" />
<TextView
android:id="#+id/header_cell4"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="#string/cell_4_weight"
android:gravity="center_vertical"
android:paddingRight="12dp"
android:text="#string/table_header_scheduled"
android:textSize="11dp" />
<TextView
android:id="#+id/header_cell5"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="#string/cell_5_weight"
android:gravity="center_vertical"
android:paddingRight="12dp"
android:text="#string/table_header_status"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/table_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:background="#FFFFFF"
android:orientation="vertical" >
<ListView
android:id="#+id/list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00FF00" />
</LinearLayout>
I may be missing something glaring, but for the life of me, I cant see it. Can anyone help?
Thanks a million..
This is because you have kept LinearLayout's height(the one wrapping listview) "wrap_content".Fixing its size to some dip would solve your problem.
Also make listview's height "fill_parent" then.
EDIT :
try this way:
...
<ListView
android:id="#+id/list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ListView>
in upper two layouts,you user 0.2 and 0.4 as weight but in lower two layouts,you users 3 and 1...try it former way and see,if it can help you.also try making height of LinearLayout(the one wrapping listview) to 0dip.
Maybe it is late, but I could help someone.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="Content 1" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#00ff00">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="Content 2" />
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/linearLayout2"
android:layout_below="#id/linearLayout1"
android:background="#00f0f0"></ListView>
Result:
Ok.. after consulting this post I came up with a fix
Remove the LinearLayout outside the ListView, its superfluous.
Add a height of '0px' (which I've found around the web) to the ListView ensures it obeys the android:weight parameter properly.
Hope this helps.
Remove the weight of id/filter.
Let the ListView have a weight of 1 with fill_parent height.
Remove the listView's immediate parent.
One other thing you missed, is to set the weightSum=sum_of all_child_weight in your root. That should fix the problem.