Search code examples
javaandroidxmlinvisible

Android .xml file, items invisible when adding


I'm building an application on Android Studio and I have with the widgets/items: when I add one to the .xml file, it appears invisible. Everything I put is invisible: Buttons, TextViews, Images, etc.

Here's the code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip" >

<ImageView
    android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="6dip"
    android:contentDescription="TODO"
    android:src="@drawable/ic_launcher"
    android:onClick="blActivity"
    android:nestedScrollingEnabled="false" />

<TextView
    android:id="@+id/secondLine"
    android:layout_width="fill_parent"
    android:layout_height="26dip"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@id/icon"
    android:ellipsize="marquee"
    android:singleLine="true"
    android:text="Calculate the volume of a ball by radius"
    android:textSize="12sp"
    android:nestedScrollingEnabled="false"
    android:onClick="blActivity" />

<TextView
    android:id="@+id/firstLine"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/secondLine"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_alignWithParentIfMissing="true"
    android:layout_toRightOf="@id/icon"
    android:gravity="center_vertical"
    android:text="Ball Volume Calculator"
    android:textSize="16sp"
    android:onClick="blActivity" />

Could anyone help me to find the origin of this problem?


Solution

  • Try this

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="6dip" >
    
        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentBottom="true"
            android:layout_alignParentTop="true"
            android:layout_marginRight="6dip"
            android:contentDescription="TODO"
            android:src="@drawable/ic_launcher"
            android:onClick="blActivity"
            android:nestedScrollingEnabled="false" />
    
        <TextView
            android:id="@+id/secondLine"
            android:layout_width="fill_parent"
            android:layout_height="26dip"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@id/icon"
            android:ellipsize="marquee"
            android:singleLine="true"
            android:text="Calculate the volume of a ball by radius"
            android:textSize="12sp"
            android:nestedScrollingEnabled="false"
            android:onClick="blActivity" />
    
        <TextView
            android:id="@+id/firstLine"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/secondLine"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_alignWithParentIfMissing="true"
            android:layout_toRightOf="@id/icon"
            android:gravity="center_vertical"
            android:text="Ball Volume Calculator"
            android:textSize="16sp"
            android:onClick="blActivity" />
    </RelativeLayout>