J'ai une liste d'images nommées. Je veux que le nom apparaisse noir sous l'image. Voici le code .xml pour la paire d'image + nom:Pourquoi le texte n'apparaît-il pas sous l'image?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="100dp"
android:clickable="true"
android:padding="3dp">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/text"
android:text="This is my text"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_below="@+id/image"
android:textColor="#000000"
android:maxLines="1"
android:ellipsize="end"/>
</RelativeLayout>
Cependant, le nom ne figure pas:
On dirait que le nom est caché pour une raison quelconque. POURQUOI?
Je joins un code Java complet:
public class ImageNamePair extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageView;
public ImageNamePair(View v) {
super(v);
textView = (TextView) v.findViewById(R.id.text);
imageView = (ImageView) v.findViewById(R.id.image);
}
}
// In another file we render the images
public void onDataChange(final DataSnapshot dataSnapshot) {
viewHolder.textView.setText(getText(dataSnapshot));
ImageRenderer.renderImage(getImage(dataSnapshot));
}
Essayez d'ajouter des mots dans textView. 'android: text =" Ceci est mon texte "' –
@John Fait, toujours sans effet. – mercury0114
Ceci est une supposition pure, mais peut-être que votre texte est derrière votre image puisque votre hauteur d'image est '" match parent "' –