Je construis ma mise en page personnalisée pour mon application Android et j'essaye d'ajouter l'élévation à un LinearLayout mais ça ne marche pas, j'ai essayé beaucoup de solutions trouvées sur le web mais rien avec Succès.Elevation ne fonctionne pas sur LinearLayout
Mon xml est la suivante:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/admin_gray"
app:civ_border_width="2dp"
app:civ_border_color="@android:color/darker_gray"
android:layout_marginRight="10dp"/>
<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="vertical">
<TextView
android:id="@+id/tvNewsAggiuntoCommentoDescrizione"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username ha commentato una ricetta:"/>
<TextView
android:id="@+id/tvNewsAggiuntoCommentoData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="25/05/1989 12:58:07"
android:textColor="@android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
android:elevation="10dp">
<FrameLayout 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/rounded_linear_layout_tile_ricetta"
android:layout_marginBottom="5dp"
>
<ImageView
android:id="@+id/imageViewRicetta"
android:layout_width="match_parent"
android:layout_height="150dp"
android:src="@mipmap/cibo"
android:scaleType="centerCrop"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Antipasto"
android:background="@color/colorCategoriaRicetta"
android:layout_alignBaseline="@id/imageViewRicetta"
android:layout_gravity="right|top"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white"
android:padding="3dp"
android:id="@+id/tvCategoriaRicetta"
android:elevation="4dp"/>
<TextView
android:id="@+id/tvTitoloRicetta"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Maxi hamburger con maionese"
android:background="@color/colorBackgroundTextViewNomeRicetta"
android:layout_alignBaseline="@id/imageViewRicetta"
android:layout_gravity="left|bottom"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/white"
android:paddingLeft="5dp"
android:textStyle="bold" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageViewFotoAltroUtente"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:src="@drawable/admin_gray"
app:civ_border_width="2dp"
app:civ_border_color="@android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/tvUsernameUtenteCommento"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Username"/>
<TextView
android:id="@+id/tvNewsAggiuntoCommentoCommento"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Questo è il testo di esempio di un commento a una ricetta"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Attention, la mise en page avec l'altitude est pas le top LinearLayout, c'est la mise en page avec l'attribut "élévation" ...
Pouvez-vous aider moi de trouver une solution pour obtenir l'élévation correctement?
Merci beaucoup.
Pouvez-vous donner un exemple capture d'écran mockup de ce vous voulez que les résultats ressemblent? –
La meilleure façon d'utiliser l'élévation est dans une cardview. Sinon, c'est trop bogué. – AeriaGlorisia