ListView's first entry always incorrect for RTL - android

For some reason, the first entry in my ListView is always flipped the wrong way around when I use RTL. For example:
Additional information:
The ListView is in a DialogFragment.
I HAVE updated my manifest to support RTL (the rest of the app works fine)
The ListView has an Adapter, the layout per item looks like:
<ImageView
android:id="#+id/dropdown_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/photo_button_disabled"
android:layout_gravity="center_horizontal"/>
<ImageView
android:id="#+id/count_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:scaleType="fitCenter"
android:layout_alignEnd="#+id/dropdown_icon"
android:layout_alignRight="#+id/dropdown_icon"
android:layout_alignStart="#+id/dropdown_icon"
android:layout_alignLeft="#+id/dropdown_icon"
android:layout_alignTop="#+id/dropdown_icon"
android:layout_alignBottom="#+id/dropdown_icon"
android:adjustViewBounds="true"/>
While the layout for the Dialog Fragment looks like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:background="#drawable/rounded_bg">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:textStyle="bold"
android:textSize="#dimen/dialog_title"
android:padding="10dp"/>
<LinearLayout
android:layout_below="#+id/title"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- This table should be populated with all the different options -->
<ListView
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/entry_list"
android:divider="?android:attr/dividerHorizontal"
android:showDividers="middle"
android:background="#color/overlay"
android:descendantFocusability="afterDescendants"
android:animateLayoutChanges="true">
</ListView>
<!-- The save and clear buttons-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="#dimen/general_padding"
android:paddingTop="#dimen/general_padding"
android:paddingRight="#dimen/general_padding">
<TextView
android:id="#+id/warning_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="#string/recon_value_required"
android:visibility="gone"
android:textColor="#color/warningColour"
android:layout_marginBottom="#dimen/list_vertical_margin"/>
<LinearLayout
android:id="#+id/button_container"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_below="#id/warning_label"
android:paddingBottom="#dimen/general_padding">
<Button
android:id="#+id/clear_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/rounded_button"
android:text="#string/clear"
android:textColor="#color/buttonTextColour"
android:layout_weight="1"
android:foreground="?attr/selectableItemBackground"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"/>
<Button
android:id="#+id/save_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/rounded_button"
android:text="#string/save"
android:textColor="#color/buttonTextColour"
android:layout_weight="1"
android:foreground="?attr/selectableItemBackground"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I'm not sure what else to try. I have fiddled with the different layouts. Changing orientation doesn't fix the issue. Any help would be greatly appreciated.

Related

Loading bar covers view

Hi there I am trying to use this lib into my app https://github.com/jlmd/AnimatedCircleLoadingView I want it to on top of that layout, can someone please show me ho it is done? I trying adding it but it either covered the whole screen or it would occupy a part of layout completly
<?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:background="#color/postBg"
android:orientation="vertical"
tools:ignore="ContentDescription">
<include
android:id="#+id/app_bar"
layout="#layout/app_bar"/>
<LinearLayout
android:id="#+id/newStatusHeader"
style="#style/newStatusHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/postOwnerImage"
android:layout_width="60dp"
android:layout_height="60dp"/>
<LinearLayout
android:id="#+id/headerInfoContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical"
android:padding="#dimen/postsItemMargin">
<TextView
android:id="#+id/postOwnerName"
style="#style/postOwnerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/postPrivacy"
style="#style/postPublishDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/publicPrivacy"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E9E9E9"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circle_loading_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
app:mainColor="#color/primaryColor"
app:secondaryColor="#color/primary_high_light"
/>
<LinearLayout
android:id="#+id/newStatusBody"
style="#style/newStatusBody"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#id/circle_loading_view"
android:layout_weight="1"
android:background="#color/white"
android:orientation="vertical">
<ImageView
android:id="#+id/imagePreview"
android:layout_width="match_parent"
android:layout_height="170dp"
android:scaleType="centerCrop"
android:visibility="gone"/>
<EditText
android:id="#+id/statusEdittext"
style="#style/statusEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="top|left"
android:hint="#string/urStatus"
android:inputType="textMultiLine"
android:padding="5dp" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/placePreviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_place_black"/>
<TextView
android:id="#+id/placeValuePreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="Rue Ibn ElArabi, Agadir 80000, Morocco"
android:textColor="#color/primary_high_light"/>
<TextView
android:id="#+id/removePlace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:textStyle="bold"
android:textColor="#android:color/holo_red_light"
android:text="X"/>
</LinearLayout>
<LinearLayout
android:id="#+id/urlPreviewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:src="#drawable/ic_insert_link_black"/>
<TextView
android:id="#+id/urlValuePreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="https://www.atouchlab.com"
android:textColor="#color/primary_high_light"/>
<TextView
android:id="#+id/removeLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="4dp"
android:textStyle="bold"
android:textColor="#android:color/holo_red_light"
android:text="X"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E9E9E9"/>
<LinearLayout
android:id="#+id/newStatusFooter"
style="#style/newStatusFooter"
android:layout_width="match_parent"
android:layout_height="65dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="65dp"
android:layout_weight="1">
<ImageButton
android:id="#+id/addPhoto"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_camera_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/addPlace"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_place_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/addLink"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_insert_link_button"
android:layout_gravity="center" />
<ImageButton
android:id="#+id/changePrivacy"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_privacy_button"
android:layout_gravity="center" />
</LinearLayout>
<ImageButton
android:id="#+id/sendStatus"
style="#style/actionAreaBtns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bg_publish_button"
android:layout_gravity="center" />
</LinearLayout>
</LinearLayout>
lib .xml
<com.github.jlmd.animatedcircleloadingview.AnimatedCircleLoadingView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/circle_loading_view"
android:layout_width="250dp"
android:layout_height="250dp"
android:background="#color/background"
android:layout_centerInParent="true"
app:mainColor="#color/main_color"
app:secondaryColor="#color/secondary_color"
/>
it either covered the whole screen or it would occupy a part of layout completly
That's because the main content's root view in your layout is a vertical LinearLayout, which arranges all its children in a single direction, one stacked after the other.
If you want the loading indicator to float on top of all the other layout elements (i.e. in the center of the screen), you'll need something like a RelativeLayout or FrameLayout. This should become the root for all elements that potentially need overlapping.
I'm not going to copy-paste your whole layout, so imagine a simplified version where you have your content and the loading indicator. To position the latter on top of the former using a FrameLayout would go like this:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
< main content root />
< loading indicator on top of main content />
</FrameLayout>
Of course you can wrap the FrameLayout on its turn in some other element to allow for screen decorations like a Toolbar etc.
This is pretty basic Android stuff and nothing that hasn't been asked before. I suggest to do a little more reading (plenty of resources readily available) and do a search before asking.

How to create correctly the following design

So the design that i want is similar to this
enter image description here
What i have done so far is this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="20dp"
android:paddingStart="20dp"
android:paddingEnd="20dp">
<ImageView
android:layout_width="120dp"
android:layout_height="180dp" />
<LinearLayout
android:layout_width="200dp"
android:layout_height="180dp"
android:orientation="horizontal"
android:background="#FFF"
android:layout_marginStart="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Article Title"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_gravity="end"
android:gravity="end"
android:text="10/11/2017"
android:paddingTop="10dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I don't undesrtand how can i make the same ui usingLinearLayout.
I'm using LinearLayout so that i can use it with recyclerView later on, this design will be a list, can some one tell me what am i doing wrong?
Anyone have a clue about this ?
You don't have to use LinearLayout for RecyclerView items. You can use any layout for that.

Listview at the bottom that i have designed for android doesnt show up entirely

You can see the code below that belongs layout design.
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="5dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/profilePic2"
android:layout_width="#dimen/feed_item_profile_pic"
android:layout_height="#dimen/feed_item_profile_pic"
android:scaleType="fitCenter" >
</ImageView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="#dimen/feed_item_profile_info_padd" >
<TextView
android:id="#+id/name2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/feed_item_profile_name"
android:textStyle="bold" />
<TextView
android:id="#+id/timestamp2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/timestamp"
android:textSize="#dimen/feed_item_timestamp" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textCategory2"
android:layout_weight="1"
android:textStyle="normal|bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/content2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/feed_item_status_pad_left_right"
android:paddingRight="#dimen/feed_item_status_pad_left_right"
android:paddingTop="#dimen/feed_item_status_pad_top"
android:layout_weight="1"/>
<ImageView
android:id="#+id/contentImage2"
android:layout_width="match_parent"
android:background="#color/white"
android:scaleType="fitCenter"
android:visibility="visible"
android:cropToPadding="false"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:srcCompat="#drawable/bg_parent_rounded_corner"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:isScrollContainer="false"
android:keepScreenOn="false"
android:measureWithLargestChild="false"
android:verticalScrollbarPosition="defaultPosition"
android:paddingBottom="10dp">
<TextView
android:text="#string/yorumlar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:layout_weight="1"/>
<ListView
android:layout_width="match_parent"
android:id="#+id/comList"
android:layout_height="wrap_content"
android:layout_centerHorizontal="false"
android:clipChildren="false"
android:headerDividersEnabled="false"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
We can see details of the post showing up top of the screen, comments are at the bottom of the screen. Comments doesnt show up entirely despite of scrollview included listview and i have “layout_height:wrap_content”. First comment showing up but else doesnt show up with scroll.
Thanks for the answers
Screenshot
You have to change following things to display the list:
change the height of root linear layout from wrap content to match parent.
android:layout_height="match_parent"
do the same thing to scroll view
android:layout_height="match_parent"
3 now change the height of listview, I have given android:layout_height="500dp" this. You can adjust this with your requirement.
NOTE: List view will not work inside scrollview without giving static height. So you have to give height as 400..500dp or you can remove scrollview.

Android: center and right alignment inside LinearLayout

I have two Linear Layouts one inside the other. In the second one I have a Switch button, a TextView and a FloatingActionButton. I want to put these 3 in the same line and I want to centralize the Switch and the TextView and I want to align the FloatingActionButton on the right side of the screen. I tried to use marginLeft to force them to go to the position I want but I believe this is not the correct way.
Here's my code (right now the 3 components are already in the same line):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:weightSum="1" >
<Switch
android:id="#+id/mySwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="140dp"
android:layout_marginTop="20dp"
android:theme="#style/SCBSwitch"
/>
<TextView
android:id="#+id/OpenClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:text="Open"
android:textSize="20dp"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/action_find_location"
android:layout_width="277dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="75dp"
android:layout_marginRight="10dp"
android:src="#drawable/calendar_today"
fab:backgroundTint="#color/theme_color"
fab:borderWidth="0dp"
fab:elevation="9dp"
fab:rippleColor="#color/toolbar_title_color"
fab:fabSize="mini"/>
</LinearLayout>
</LinearLayout>
Just took your code and made some changes. Please check if it works fine
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:weightSum="3">
<Switch
android:id="#+id/mySwitch"
android:layout_width="50dp"
android:layout_height="50dp"
android:theme="#style/SCBSwitch"
android:layout_gravity="start"
android:gravity="center"
android:layout_weight="1"/>
<TextView
android:id="#+id/OpenClose"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Open"
android:textSize="20dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_weight="1"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/action_find_location"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/calendar_today"
fab:backgroundTint="#color/theme_color"
fab:borderWidth="0dp"
fab:elevation="9dp"
fab:rippleColor="#color/toolbar_title_color"
fab:fabSize="mini"
android:layout_gravity="end"
android:gravity="center"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
delete android:weightSum="1" from the LinearLayout and do something like that:
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<Switch
android:id="#+id/mySwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
same to the TextView, and with the FAB delete:
android:layout_gravity="end"
android:gravity="center"
android:layout_weight="1"

wrap_content leaving extra white space at bottom of screen for ViewPager

enter image description here
Wrap_content inside 2nd linearlayout leaving the extra white space at bottom of screen but if give hardcoded value it's working fine. any issue with wrap_content ? Here I am using this .xml on viewPager anyone have idea about this issue.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/white_noround">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/canceledPesananTgl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ABCDEFGHI"
android:textSize="14sp"
android:padding="10dp"
android:textStyle="bold"
android:textColor="#999999"
android:fontFamily="sans-serif-light"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-15dp"
android:text="29 JAN 2016"
android:textSize="14sp"
android:padding="10dp"
android:textStyle="bold"
android:textColor="#999999"
android:id="#+id/canceledDate"
android:fontFamily="sans-serif-light"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:visibility="visible"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/image_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".9"
android:orientation="vertical"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/canceled_dummuyImage1"
android:background="#drawable/imageview_border"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:src="#drawable/empty_photo"/>
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:id="#+id/canceled_dummuyImage2"
android:background="#drawable/imageview_border"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:src="#drawable/empty_photo"/>
<LinearLayout
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_marginTop="20dp"
android:background="#drawable/imageview_border">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"
android:id="#+id/canceledImage"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:src="#drawable/empty_photo"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight=".4"
android:paddingBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SONY Memory Card Playstation 2"
android:textSize="16sp"
android:id="#+id/productName"
android:fontFamily="sans-serif-light"
android:textColor="#333333"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="#+id/productStatus"
android:textSize="14dp"
android:text="Dalam pengiriman"
android:textStyle="normal"
android:fontFamily="sans-serif"
android:textColor="#f7931e"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
The Problem is here. see this Parent LinearLayout.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight=".4"
android:paddingBottom="10dp">
In this You have used android:paddingBottom="10dp" so the child' element work fine but The Extra white Space is for it's parent layout to Solve your problem remove android:paddingBottom="10dp" line.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:visibility="visible"
>
in the above linear layout instead of layout_height as 150dp try giving wrap_content
What I was doing with above .xml was to populate list of items using listView on ViewPager. So the above .xml is listItem .xml so we should always go with below code.This line worked for me android:layout_height="wrap_content".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/white_noround"/>

Resources