Dans mon fragment XML j'ai une image qui fonctionne comme arrière-plan. Dans cette même mise en page, j'ai un LinearLayout qui contient des boutons qui doivent être affichés horizontalement sur la vue et avoir la même largeur que l'arrière-plan. Mon code le dimensionne à la largeur de l'écran à cause de wrap_content. Comment puis-je le dimensionner en imageview?Taille LinearLayout à la largeur de ImageView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="45sp" >
<ImageView
android:src="@drawable/background_detail_view"
android:id="@+id/detailview_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/detailview_background_description" />
<!-- more widgets -->
<LinearLayout
android:id="@+id/detail_button_container"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_above="@+id/titel" >
<Button
android:id="@+id/detail1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1"/>
<Button
android:id="@+id/detail2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2"/>
<Button
android:id="@+id/detail3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3"/>
<!-- more buttons -->
</LinearLayout>
J'ai essayé d'obtenir la largeur et l'affectation que programatically tot nouvelles layoutparams mais qui retourne 0 parce que la vue isnt a rendu encore.
jeah .. bonne réflexion. Besoin de changer la mise en page car beaucoup a été défini "sous le ImageView" et doit être réorganisé. Je vous tiens au courant –