How to layout a similar layout?

84b35d96d2864893b15a5ac9d9e467dc.png
Got it all, except for the image. You need to:
  • took a fixed size, and that goes for him, hiding (similar to html background cover),
  • beyond the edge of the main unit (similar to a negative marging in html).

I would be grateful for hints.

Clarification: need to mark up native in the application under Android.
July 5th 19 at 00:04
5 answers
July 5th 19 at 00:06
yeah, but the TC-u need one to impose, not khtml. theme ***** not disclosed! - Montana_Abshire commented on July 5th 19 at 00:09
July 5th 19 at 00:08
d6055785cb734be9b704740eb77a003f.png
<?xml version="1.0" encoding="utf-8"?>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#D4D7DC" android:layout_width="parent" android:layout_height="parent" android:orientation="vertical" android:gravity="center_horizontal">
 <android.support.v7.widget.cardview android:layout_width="parent" android:layout_height="wrap content" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_margintop="30dp">
 <textview android:layout_width="wrap content" android:layout_height="wrap content" android:textcolor="dark" android:layout_margintop="20dp" android:layout_marginleft="10dp" android:layout_marginbottom="20dp" android:text="Some text..." android:textsize="17dp">
</textview></android.support.v7.widget.cardview>
 <linearlayout android:layout_width="wrap content" android:layout_height="250dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:weightsum="100">
 <imageview android:layout_width="parent" android:layout_height="parent" android:scaletype="centerCrop" android:layout_marginbottom="-6dp" android:layout_margintop="-6dp" android:src="@drawable/Desert">
</imageview></linearlayout>
 <android.support.v7.widget.cardview android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_width="parent" android:layout_height="wrap content">
 <textview android:layout_width="wrap content" android:layout_height="wrap content" android:textcolor="dark" android:layout_margintop="20dp" android:layout_marginleft="10dp" android:layout_marginbottom="20dp" android:text="Some Other text..." android:textsize="17dp">
</textview></android.support.v7.widget.cardview>
</linearlayout>
I understood the logic. Check and unsubscribe. - Montana_Abshire commented on July 5th 19 at 00:11
Only I would do 1 card view. - parker_Blan commented on July 5th 19 at 00:14
How? - yvette commented on July 5th 19 at 00:17
July 5th 19 at 00:10
The look in the direction of android:scaleType, like there was something similar
Yes, this property helps to stretch the image width proportionally. But how to make it go beyond the parent unit, so far a mystery. - Montana_Abshire commented on July 5th 19 at 00:13
July 5th 19 at 00:12
you have to be so

<android.support.v7.widget.cardview <linearlayout>
<textview>
<imageview>
<textview>

</textview></imageview></textview></android.support.v7.widget.cardview>
In this case, the picture will be inside the card, and beyond it will not go. - Montana_Abshire commented on July 5th 19 at 00:15
Exactly. I already checked earlier. - parker_Blan commented on July 5th 19 at 00:18
July 5th 19 at 00:14
From the solution with two CardView suggested above, had to be abandoned, because in my opinion it contradicts the very concept of CardView ("one card - one CardView"). So replaced it with a RelativeLayout and set the margins approximately as follows:

<linearlayout>
 <relativelayout ... android:layout_marginstart="10dp" android:layout_marginend="10dp">
<textview>
<textview>
</textview></textview></relativelayout>
<imageview>
 <relativelayout ... android:layout_marginstart="10dp" android:layout_marginend="10dp">
<textview>
<textview>
</textview></textview></relativelayout>
</imageview></linearlayout>


Now think of how to lift the picture and drop shadow. Try this:

<imageview android:layout_width="parent" android:layout_height="wrap content" android:adjustviewbounds="true" android:scaletype="fitCenter" android:elevation="2dp" android:background="@drawable/image_bg"></imageview>


where

<!-- res/drawable/image_bg.xml -->
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
 <stroke android:width="2dip" android:color="#4e4e4e">
</stroke></shape>

But the result is not the same.
But what if the other can be done. It is possible that in the example you gave was typeset using two CardView, but I still hope that there is a way to impose such a layout without using the two CardView. - Montana_Abshire commented on July 5th 19 at 00:17

Find more questions by tags Android