I am trying to achieve the following complex layout in my android app but with no luck
for that i have wrote the following layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="6dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="8dip"
android:layout_toRightOf="@+id/list_item_title">
<ImageView
android:layout_weight="0.6"
android:id="@+id/list_item_image"
android:layout_width="90dp"
android:layout_height="72.0dip"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_weight="0.6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:layout_alignParentTop="true"
android:layout_above="@+id/list_item_title" >
<ImageView
android:id="@+id/feedIcon"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/cnn"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/feedName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/feedIcon"
android:text="CNN International"
android:layout_centerHorizontal="true"
android:textSize="@dimen/abc_text_size_caption_material"
android:paddingLeft="4dp" />
<ImageButton
android:id="@+id/btnOverFlow"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/btn_feed_action"
android:src="@drawable/ic_more_grey"
android:layout_alignParentRight="true"
android:paddingRight="4dp"
android:paddingLeft="8dp" />
<ImageView
android:id="@+id/timeIcon"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/time"
android:layout_toLeftOf="@+id/timeStamp"
android:paddingLeft="4dp" />
<TextView
android:id="@+id/timeStamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/btnOverFlow"
android:text="Yesterday"
android:layout_centerHorizontal="true"
android:textSize="@dimen/abc_text_size_caption_material"
android:paddingLeft="4dp" />
</RelativeLayout>
<TextView
android:id="@+id/list_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="8.0dip"
android:text="Why women's watches are having a moment"
android:ellipsize="end"
android:maxLines="3"
android:minLines="1"
android:textIsSelectable="false"
android:textSize="@dimen/abc_text_size_subhead_material"
android:paddingTop="4dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:layout_below="@+id/list_item_title">
<ImageButton
android:id="@+id/btnComments"
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="6dp"
android:background="@drawable/btn_feed_action"
android:src="@drawable/ic_comment_outline_grey"
/>
<ImageButton
android:id="@+id/btnLike"
android:layout_width="24dp"
android:layout_height="24dp"
android:padding="6dp"
android:layout_toRightOf="@+id/btnComments"
android:background="@drawable/btn_feed_action"
android:src="@drawable/ic_heart_outline_grey"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView >
the top most Relative layout that contains feed source icon
, feed source name
, timestamp
and ovweflow icon
is not appearing at all either in xml editor design mode nor during my app run time.
Moreover, i feel my code is not provisionally written.
UPDATE:
- I have followed the solution given by r7v , i got the following layout which is fine but still have problem with post image as it has to shrink to the size similar to the red box shown on the screenshot
Also, i think the layout padding , margins as not as material design standards
Can you please help me on how achieve layout similar as in the attached image?
Thank You