I have a gif image as
However using glide i do this
Glide.with(this)
.load(Uri.parse("file:///android_asset/" + "stickers/" + emoji))
.into(gifImage);
What i get is
Exactly what is going on, I have tried GifImageView library too and result is same. How can i parse gif image properly in android?
after adding datasource
<ImageView
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:visibility="gone"
android:layout_height="100dp"
android:layout_width="100dp"
android:id="#+id/chateeGifImage"
/>
try like this
Glide.with(con).load(url).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(ivImage);
Related
I'm trying to make a rounded shape like this :
The code below works great on a device with 6.7" as screen size.
<com.google.android.material.card.MaterialCardView
android:id="#+id/resultHolder"
android:layout_width="232dp"
android:layout_height="376dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:gravity="center"
android:rotation="15"
android:outlineProvider="background"
android:theme="#style/Theme.MaterialComponents.Light"
app:cardBackgroundColor="#color/black"
app:cardCornerRadius="120dp"
app:cardElevation="0dp"
app:strokeColor="#color/green_neon"
app:strokeWidth="6dp">
<ImageView
android:src="#drawable/thumbnail"
android:id="#+id/resultImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop" />
</com.google.android.material.card.MaterialCardView>
But when I test the app on device with 5.1" as screen size. I get this :
You're setting
android:layout_width="232dp"
android:layout_height="376dp"
which are fixed values when you put app:cardCornerRadius="120dp" which is very high it does not get the space to complete it's 120dp radius on a smaller screen..
Use a background drawable or a different solution. This solution will work perfectly only in the 6.7 inch screen that you have and only that
I have a circular image:
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/circularIcon"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/img_gr"
app:civ_border_color="#EEEEEE"
app:civ_border_width="1dp"
app:civ_shadow="true"
app:civ_shadow_radius="3"
android:layout_gravity="center_horizontal"
app:civ_shadow_color="#8C0F0F"
android:layout_weight="1"
android:visibility="visible"/>
And I want to add around it, something like a "frame":
https://i.stack.imgur.com/uadIp.png
so the frame would be exactly wrapping the circular image view
If you want to add a simple frame to your circular ImageView you can use this library CircleImageView
I've been working on a simple java application, and wanted to add a logo as the homescreen is fairly empty. I tried using an image view, and after it didn't work I googled tutorials to make sure I was initiating it correctly. I didn't see any difference, but the actual image wouldn't load.
Xml code for image view:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src = "#drawable/logo"
android:layout_gravity="center"
android:contentDescription="#string/logo"
android:layout_below="#+id/textView"
android:layout_above="#+id/txtBody"
android:layout_alignRight="#+id/txtBody"
android:layout_alignEnd="#+id/txtBody"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:visibility="visible"
android:maxHeight="600dp"
android:maxWidth="600dp"
android:minHeight="100dp"
android:minWidth="100dp"
android:clickable="false" />
And here's a picture of the layout preview (With an arrow pointing to the outline of where it should be, and the resource circled in the correct folder) along with a picture of the logo
Any dice if you add
android:scaleType="fitCenter"
android:adjustViewBounds="true"
Edit: also are we sure nothing is overlapping it?
I want show image in ImageView, but don't show it. I use XML code and Java code but don't show. show in simulator but in real devices don't show. tested on LG G2, HTC One X, Samsung Galaxy S3.
my xml code :
<ImageView
android:id="#+id/sms_dialog_header"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:background="#drawable/show_sms_header" />
my java code :
Dialog_Header_Img = (ImageView) findViewById(R.id.sms_dialog_header);
Dialog_Header_Img.setImageResource(R.drawable.show_sms_header);
I used to be separated from each.
Please tell me the solution
First of all you should set image in xml by code:
android:src="#drawable/show_sms_header"
not by android:background, well you can set background to color or other image but your main image you should set by android:src
If you changing something about your image, leave first line in your code that you show, and delete second, if setting image is only thing you set, then you can delete both, because you set source of image in xml.
The "src" attribute should be set to your drawable if you want it to be "centerCrop" correctly.
Check this out :
<ImageView
android:id="#+id/sms_dialog_header"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="#drawable/show_sms_header" />
Make sure that your file, called "show_sms_header", is in your drawable ( /res/drawable) directory.
I have imageview with resolution of 430x871 in folders xxhdpi, xhdpi and hdpi. But when I run app, on 5" Xperia Z (xxhdpi) screen it works normally (1. picture) but on 4.7" Amazon Phone (xhdpi) it's smaller (2. picture). Altough when I run it on Amazon Fire HD 8.9 or 7 or 6, (all xdpi) it works too...
How can I stretch in on that Amazon Phone?
Here is XML code of the Imageview:
<ImageView
android:id="#+id/matter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="center"
android:src="#drawable/matter"
/>
if aspect ratio is not important for you use:
android:scaleType="fitXY"
but if yes try this:
android:scaleType="fitCenter"
and also change this:
android:layout_height="match_parent"
There's a property called :
android:scaleType="fitXY"
inside ImageView tag.