As i am going to make Alerting App, I am using my website instead of XML code. But for going to my alert activity for web Activity, I made an intent which works onclick on my small image view.
It’s my XML code Below:
activity_web.xml
<?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=".WebActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
</WebView>
<ImageView
android:id="@+id/imageView"
android:layout_width="81dp"
android:layout_height="75dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
tools:srcCompat="@drawable/bell_icon" />
</RelativeLayout>
But the main Problem is that imageview is not visible when I install’s the app in my mobile.
It is also visible in my android Studio Layout.
You Check My Android Studio Layout here
Now tell me what should do for making visible it in final build apk which will work in my mobile.
2
Answers
you can set it properly by using constraint layout, here is a code maybe it’s work!
In this i set an ImageView at the top and webview is set at bottom of ImageView.
you are using wrong attribute namespace, I’m supprised that AS preview tool is showing this image, it shouldn’t. but your
ImageView
is there on device, it is clickable (wehn you set so), it just have transparent content (wrongly resolvedsrcCompat
attr, as below). as a test you may addandroid:background="#789810"
tag,ImageView
will show up with visible background (still without image)in your code you have
tools
namespace points on "some tools", like usedtools:context=".WebActivity"
. for setting custom attribute of particularView
you have to use (custom) resources namespace, these are declared in your XML withxmlns:app="http://schemas.android.com/apk/res-auto"
line, thus you should use below linebtw. if you are using
srcCompat
the you should also useAppCompatImageView
. it works with usualImageView
only because AS project by default is exchanging allImageView
s toAppCompatImageView
s during building project to APK/bundle. this behavior may be changed or disabled, then yourImageView
will stay without any image set. fully proper line for setting image is defaultsrc
attribute ofImageView
, so:android
namespace in here as this attribute belong to framework ("built-in"), not some additional library andView
(AppCompatImageView
comes from AppCompat or AndroidX library)