Reputation: 5
I have an imageView that should display the icon of an profile from an url. But it can happen that the url has no image and for this case i want to have an textview underneath it. If the imageView is "empty" the user should b able to see the text n the textView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.lolstats.DisplayDataActivity">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imgRound"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#00000000"
android:foregroundGravity="center"
android:visibility="visible"
app:border_color="#ffffff"
app:border_width="10dp" />
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_above="@+id/TVsummoerName"
android:layout_centerHorizontal="true"
android:layout_marginBottom="11dp"
android:gravity="center"
android:text="If you can read this your SummonerIcon isn't implemented yet." />
<TextView
android:id="@+id/TVsummoerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/imgRound"
android:gravity="center" />
</RelativeLayout>
Upvotes: 0
Views: 522
Reputation: 16
put ImageView in another relative layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.lolstats.DisplayDataActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:id="@+id/rl"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imgRound"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="#00000000"
android:foregroundGravity="center"
android:visibility="visible"
app:border_color="#ffffff"
app:border_width="10dp" />
</RelativeLayout>
<TextView
android:id="@+id/TVsummoerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/rl"
android:gravity="center" />
</RelativeLayout>
The TextView will be below the relative layout Now programmatically set imageView invisible
ImageView.setVisibility(View.INVISIBLE);
Upvotes: 0
Reputation: 567
you can set the visibility
imageview.setVisibility(View.GONE); // visible / invisible acc to your need
Upvotes: 0