In my app I have several fragments with different ListViews, but for all them I want to use the same empty view, so I created a separate layout with the empty view and added it to the other layouts using
<include
android:id="#+id/empty"
layout="#layout/empty_view"/>
Everything works as expected but now I'm trying to make that view clickable so I can reload ListView when the user taps on the empty view, however I can't make it work. Any idea on how to do it?
This is what I have tried so far:
(empty_view.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="center"
android:src="#drawable/error_icon"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#929292"
android:textSize="24sp"
android:text="#string/empty_list_error"/>
</LinearLayout>
fragment_list.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<Spinner
android:id="#+id/spinner_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/activity_vertical_margin"
android:layout_marginLeft="#dimen/activity_vertical_margin"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<include
android:id="#+id/empty"
layout="#layout/empty_view"/>
<ProgressBar
android:id="#+id/loading_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:indeterminate="true"
style="#android:style/Widget.Holo.ProgressBar.Large"/>
<LinearLayout
android:id="#+id/list_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/primary_color"
android:padding="#dimen/activity_vertical_margin"
android:layout_below="#id/spinner_filter"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="wrap_content"
android:textColor="#color/white_90pct"
android:textAllCaps="true"
android:text="#string/subject_indicator"/>
<View
android:layout_width="1dp"
android:layout_height="15dp"
android:layout_gravity="center_vertical"
android:background="#color/light_color"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="end"
android:textColor="#color/white_90pct"
android:textAllCaps="true"
android:text="#string/grade_indicator"/>
</LinearLayout>
<ListView
android:id="#+id/semesters_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/list_header"/>
</RelativeLayout>
Java class (onCreateView)
LinearLayout emptyView = (LinearLayout) view.findViewById(R.id.empty);
emptyView.setOnClickListener(this);
I also tried adding the next attributes to the xml but still not working:
android:focusableInTouchMode="true"
android:focusable="true"
android:descendantFocusability="blocksDescendants"
Since you have already specified the linearlayout to be clickable, you just need to specify the method for the onClick event.
So add you your linearLayouts xml, the onClick attribute as below: (focusable may be needed too)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:onClick="layoutClicked"
android:focusable="true"
android:gravity="center">
Then in your code have the method to go with it
public void layoutClicked(View v)
{
// Your code here
}
Try emptyView.setOnTouchListener()
Are you including empty_view into another view that blocks descendant focusability?
Since your edit
Your ListView is on top of the empty_view and blocking clickability.
Since your empty view fills its parent, make sure your include tag for your empty view is the last in the other layout so it will be top-most in the z-order.
Related
I have layount who include one layout, duplicate two time ("include"):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorButtonNiebieski">
<!-- LAYOUT GRACZ (A) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.0"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.45"
android:scaleY="-1"
android:scaleX="-1"
android:paddingBottom="10dp">
<include
android:id="#+id/lay1"
layout="#layout/layout_pojedynek_duplikat" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.05"
android:gravity="center"
android:scaleY="-1"
android:scaleX="-1">
<TextView
android:id="#+id/txt_gracz_A_liczba_punktow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textSize="30dp"
android:textColor="#color/colorWhite"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.05"
android:gravity="center">
<TextView
android:id="#+id/txt_gracz_B_liczba_punktow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:textSize="30dp"
android:textColor="#color/colorWhite"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.45"
android:paddingBottom="10dp">
<include
android:id="#+id/lay2"
layout="#layout/layout_pojedynek_duplikat" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
layout_pojedynek_duplikat.xml
<?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:weightSum="1.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:weightSum="1.0"
android:background="#00ff0000"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:gravity="center">
<TextView
android:id="#+id/txt_gracz_A_i_B_nazwa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POLSKA"
android:textSize="40dp"
android:textColor="#color/colorWhite"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.0"
android:layout_weight="0.5"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_pojedynek_wariant_A"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:src="#drawable/argentyna"
android:padding="5dp"
android:adjustViewBounds="true"/>
<ImageView
android:id="#+id/img_pojedynek_wariant_B"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:src="#drawable/kambodza"
android:padding="5dp"
android:adjustViewBounds="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.0"
android:layout_weight="0.5"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_pojedynek_wariant_C"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:src="#drawable/watykan"
android:padding="5dp"
android:adjustViewBounds="true"/>
<ImageView
android:id="#+id/img_pojedynek_wariant_D"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:src="#drawable/polska"
android:padding="5dp"
android:adjustViewBounds="true"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
In java file I try set font for txt_gracz_A_i_B_nazwa text field:
TextView txt_gracz_A_i_B_nazwa = (TextView) findViewById(R.id.txt_gracz_A_i_B_nazwa);
txt_gracz_A_i_B_nazwa.setTypeface(myFontBold);
But this set font for only one view:
How can I fix this problem?
DO that for every view. Or create a new View class that's a child of TextView and sets the font, and use that instead of TextView.
Yes, Android's font handling sucks.
When you call Activity.findViewById(), the system will traverse your view hierarchy starting from the root until it finds a view with the given id. In other words, Activity.findViewById() will return the first view with that id in your layout. It will not return all views with that id.
For this reason, it is generally advised to not re-use ids within a single layout. However, this advice is often not practical, and you shouldn't feel bad about your current layout. But it does mean that you will need to call TextView.setTypeface() twice, and that you will need some way to access the second view with the id txt_gracz_A_i_B_nazwa.
You can do this by limiting the scope you search with findViewById(). Instead of using Activity.findViewById(), instead use View.findViewById(). So you could write something like this:
View lay1 = findViewById(R.id.lay1);
TextView txt1 = (TextView) lay1.findViewById(R.id.txt_gracz_A_i_B_nazwa);
txt1.setTypeface(myFontBold);
View lay2 = findViewById(R.id.lay2);
TextView txt2 = (TextView) lay2.findViewById(R.id.txt_gracz_A_i_B_nazwa);
txt2.setTypeface(myFontBold);
Looks like a small logic flaw. The problem with reusing the same layout two times, is that you have the identical IDs although they represent two entirely different UI elements.
lay1.findViewById(your_text_field_id).setFontType
lay2.findViewById(your_text_field_id).setFontType
Should fix you. You can't use generic findViewById as it will grab the first one and use it. Hope that helps.
I am new to android layout and having the following problem in my app:
here's the layout for fragment
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:layout_margin="0dp">
<ListView
android:id="#+id/listview_books_to_issue"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.87"
/>
<ImageView
android:id="#+id/imageView_empylist"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.87"
android:src="#drawable/ic_empty_flask"
android:visibility="gone"/>
<View
style="#style/Divider"/>
<Button
android:id="#+id/add_newbook_upcoming_issues"
android:layout_width="match_parent"
android:text="New"
android:paddingTop="5dp"
android:layout_height="0dp"
android:layout_weight="0.13"
android:drawableTop="#drawable/ic_add"
android:background="?android:attr/selectableItemBackground"/>
I turn the ImageView's(imageView_empylist) visibility on when the ListView(listview_books_to_issue) is empty, so far the button add_newbook_upcoming_issues looks good, but when the listview is populated even with a single item the button gets hidden partially in the bottom.
Here's the layout code for the item used to populate list.
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textview_upcoming_issues_book_title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:textAlignment="center"
android:gravity="center_vertical"
android:text="Title"/>
<TextView
android:id="#+id/textview_upcoming_issues_book_author"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:textAlignment="center"
android:gravity="center_vertical"
android:text="By:-Author"/>
<TextView
android:id="#+id/textview_to_issue_date"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:textAlignment="center"
android:gravity="center_vertical"
android:text="to be issued on"/>
<TextView
android:id="#+id/textview_upcoming_issues_book_no"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:visibility="gone"/>
</LinearLayout>
Don't know what's causing it, any help?
Thanks in advance :)
PS: I am using weights instead of height so that I can have a fixed ratio of screen for items. If in case this is causing the problem please mention the correct way of doing this.
EDIT found the solution here Limit height of ListView on Android
In your main layout fragment, please use RealativeLayout replace for LinearLayout. Your ListView will be layout_above for these views
I have a layout with some preferences. It works correctly in portrait, but not in landscape. I want this layout to refresh with a swiperefreshlayout, and does work. But as i i say in the title, it doesnt scroll up.
Ive been playing with a normal LinearLayout, with a RelativeLayout, using the swiperefreshlayout as the root view, playing with weights, ... but nothing. It either doesnt scroll up, or doesnt show the preferences correctly (only the 1st title). Dont know what else to try.
I should also say, i want this screen to keep a linearlayout at the bottom, fixed there. So, only the preferences would scroll.
Heres what i have right now:
<?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" >
<LinearLayout
android:id="#+id/edittexts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:elevation="8dp"
android:background="#color/primary"
android:visibility="gone"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/setwallpaperbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onActivarClick"
android:text="#string/setwallpaperbuton"
android:visibility="gone"
android:clickable="true"
android:enabled="true"/>
<EditText
android:id="#+id/edittextlocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="2dp"
android:textColor="#android:color/white"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:layout_gravity="center"
android:inputType="textMultiLine"
android:maxLines="2"
android:background="#android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/edittextupdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="2dp"
android:textColor="#android:color/white"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:layout_gravity="center"
android:inputType="text"
android:background="#android:color/transparent"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/swipelayout"
android:isScrollContainer="true"
android:layout_alignParentTop="true"
android:layout_above="#+id/edittexts">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<fragment
android:name="es.jnsoft.nowweather.PreferencesFragment"
android:id="#+id/preferencesfragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="#xml/settings"/>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
Thanks in advance.
According to the documentation,
[SwipeRefreshLayout] should be made the parent of the view that will be
refreshed as a result of the gesture and can only support one direct
child.
This clause is violated in your layout.
How to change the height of ExpandableListView when group is expanded/collapsed?
I want to change the height of ExpandableListView to fit the height of its content, so that the view will not scroll inside itself.
this is the layout for main activity.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="jp.foo.android.activity.FooActivity"
tools:ignore="MergeRootFrame" />
and this is a layout for the fragment of the main activity.
<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="wrap_content"
tools:context="jp.foo.android.fragment.FooFragment"
android:background="#color/category_bg">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:id="#+id/frameLayout">
<TextView
android:text="#string/subtitle_question_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/subtitle_category"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_horizontal|top"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/frameLayout"
android:background="#drawable/category_list_bg_shape"
android:layout_marginTop="0dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:minHeight="300dp">
<LinearLayout
android:id="#+id/category_list_progressbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/category_list"
android:transcriptMode="normal">
</ExpandableListView>
</FrameLayout>
</RelativeLayout>
Below is the actual layout.
ExpandableListView will scroll inside when it has too many contents.
I want to scroll whole screen. Not only scroll view, but with header.
I solved a similar issue putting everything into a Header. I was close to solving it the traditional ways (ie. nesting layouts, weights, ...) but I felt the solution was pretty dirty, requiring overriding methods such as onGroupClick etc... to disable the ExpandableListView's scroll, while the header thing was clean and worked flawlessly for me.
So if you want to try this approach, just put an ExpandableListView alone inside your fragment, and prepare the rest to be inserted as Header.
So in your fragment a full ExpandableListView:
<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/category_list"
android:transcriptMode="normal">
</ExpandableListView>
Then create the layout expandable_header.xml:
<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="wrap_content"
tools:context="jp.foo.android.fragment.FooFragment"
android:background="#color/category_bg">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:id="#+id/frameLayout">
<TextView
android:text="#string/subtitle_question_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/subtitle_category"
android:gravity="center_vertical|center_horizontal"
android:layout_gravity="center_horizontal|top"
android:textSize="20sp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/frameLayout"
android:background="#drawable/category_list_bg_shape"
android:layout_marginTop="0dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:minHeight="300dp">
<LinearLayout
android:id="#+id/category_list_progressbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:visibility="gone">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
And then inflate the header into the ExpandableListView:
.
.
.
View view = View.inflate(context, R.layout.expandable_header, null);
expandableList.addHeaderView(view, null, false);
.
.
.
This way the header will scroll together with the ExpandableListView, as it's inside it.
BTW, your layout has redundant elements, for example the FrameLayout that contains only a TextView. You can use only the TextView. Also the LinearLayout with the ProgressBar, if you are not using an opaque background, you could put the ProgressBar alone. The less ViewGroups you use the better the layout will perform!
I want to implement a layout like this for each row of a listview
So i created a container like 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="wrap_content"
android:orientation="horizontal"
android:clickable="false"
android:focusable="false"
>
<!--List items goes here -->
</LinearLayout>
In the getView() method of my custom adapter, I inflate this xml for each box in the image above
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="500dp"
android:clickable="true"
android:focusable="true"
android:padding="10dp"
android:background="#drawable/list_item_background"
android:focusableInTouchMode="true">
<ImageView
android:id="#+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/cnbc_default_image"/>
<ImageView
android:id="#+id/supportImageView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:visibility="gone"
android:src="#drawable/video_play_icon"
android:paddingLeft="10dp"
android:layout_above="#+id/title"/>
<TextView
android:id="#id/title"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_above="#+id/description"
style="#style/large_news_title_text_style"/>
<TextView android:id="#id/description"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:maxLines="2"
android:ellipsize="end"
android:textSize="13sp"
style="#style/large_news_title_text_style"
android:textColor="#android:color/white" />
</RelativeLayout>
and then finally add the inflated view to the linearlayout instance using
row.addView(inflatedView);
However, the end result is first box stretching across X axis. If i inspect my layout using HierachyViewer, i do see 3 RelativeLayouts inside a LinearLayout, but the first one is occupying all the space.
The thumbnail image android:id="#+id/thumbnail", seems to be taking up match_parent attribute of the LinearLayout and not its immediate container RelativeLayout.
Clarification
The list view is from ListFragment.
When adding the box layout to the list view row container i use this method call
ViewGroup container = (ViewGroup)inflater.inflate(R.layout.list_view_row_land, parent, false);
View rowItem = inflater.inflate(R.layout.list_view_row_item,null);
container.addView(rowItem);
Solved:
The problem is solved if i modify the layout of the box to
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="500dp"
android:layout_height="300dp"
android:clickable="true"
android:focusable="true"
android:padding="10dp"
android:background="#drawable/list_item_background"
android:focusableInTouchMode="true">
<ImageView
android:id="#+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/cnbc_default_image"/>
<ImageView
android:id="#+id/supportImageView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:visibility="gone"
android:src="#drawable/video_play_icon"
android:paddingLeft="10dp"
android:layout_above="#+id/title"/>
<TextView
android:id="#id/title"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_above="#+id/description"
style="#style/large_news_title_text_style"/>
<TextView android:id="#id/description"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:maxLines="2"
android:ellipsize="end"
android:textSize="13sp"
style="#style/large_news_title_text_style"
android:textColor="#android:color/white" />
</RelativeLayout>
</LinearLayout>
I still don't understand why. So any explanation of why putting a LinearLayout around solves the issue will be helpful.