J'ai une mise en page pour un élément de listview et il est affiché incorrectement (le fichier descr dépasse la date de la dernière mise à jour). Pouvez-vous s'il vous plaît m'aider à résoudre?Utilisation correcte de RelativeLayout
Si je mets
android:layout_above="@+id/lastUpdatedDt"
à l'élément bookDescr le texte entier disparaît ...
EDIT: J'ai mis à jour l'échantillon selon les commentaires
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:layout_margin="10dp"
android:background="@drawable/big_card_details"
android:clickable="true"
android:focusable="false">
<CheckBox
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/starStyle"
android:layout_marginTop="10dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/bookTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Book title"
android:textSize="16sp"
android:layout_alignBaseline="@id/icon"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/icon" />
<TextView
android:id="@+id/bookSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="470k"
android:layout_alignBaseline="@id/icon"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/lastUpdatedDt"
android:layout_width="match_parent"
android:layout_height="26dip"
android:singleLine="true"
android:text="Updated 27.04.2014 17.10"
android:textSize="12sp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_alignLeft="@id/icon" />
<TextView
android:id="@+id/bookDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:textSize="10sp"
android:text="here should be long description"
android:layout_alignEnd="@id/bookSize"
android:layout_below="@+id/bookTitle"
android:layout_marginTop="20dp"
android:layout_alignLeft="@+id/icon" />
<!-- this is the button that will trigger sliding of the expandable view -->
<ImageButton
android:id="@+id/expand_details_button"
android:src="@drawable/slide_button_details"
android:layout_alignTop="@id/lastUpdatedDt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_alignBaseline="@id/lastUpdatedDt"
android:layout_alignParentBottom="true"
android:layout_alignRight="@id/bookSize"
android:layout_alignEnd="@id/bookSize" />
</RelativeLayout>
<!-- this is the expandable view that is initially hidden and will slide out when the more button is pressed -->
<LinearLayout
android:id="@+id/details_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
>
<!-- put whatever you want in the expandable view -->
<Button
android:layout_width="match_parent"
android:layout_weight="0.3"
android:drawableTop="@drawable/ic_action_read"
android:text="@string/ReadBook"
style="@style/SlideButtonTheme" />
<Button
android:layout_width="match_parent"
android:layout_weight="0.3"
android:drawableTop="@drawable/ic_action_open_browser"
style="@style/SlideButtonTheme"
android:text="@string/OpenInBrowser" />
</LinearLayout>
</LinearLayout>
Problèmes que je vois jusqu'à présent: ** 1 ** - Vous avez trop de mises en page. ** 2 ** - Les xmlns sont répétés (WRONG !!). ** 3 ** - Vous utilisez '@ + id' au lieu de' @ id' quand REFERRING à ids ('@ + id' ne devrait être utilisé que pour CREER de nouveaux identifiants). ** 4 ** - 'fill_parent' est obsolète depuis API 8. Depuis API 8, vous devez utiliser' match_parent' –
1. Je n'ai que 3 mises en page (minimum requis pour la vue personnalisée https://github.com/tjerkw/ Android-SlideExpandableListView 2. Thx 3. Je ne le savais pas, thx 4. Mon min sdk est 8, donc je vais le changer à match_parent, thx –
1 - Vous avez 4 mises en page, vous pouvez chosifier beaucoup (éventuellement réduire à 1 ou deux ou, dans le pire des cas, 3) - Je ne vais pas étudier la question en profondeur, gardez à l'esprit que moins vous utilisez de mises en page (et moins de contrôles), plus vous obtiendrez de meilleures performances, et donc mieux expérience utilisateur –