imageview

Put a button over an ImageView

谁说胖子不能爱 提交于 2019-11-29 01:21:58
I'm newbie in Android. I would like to know if it's possible to put a button or another component over an ImageView. I've tried setting the image as a background image of a LinearLayout, but when I change between landscape and portrait mode, the image porportions are changed. Thanks a lot. Don't put the image as a background, you don't have any control on how the image is scaled. Instead, create a RelativeLayout, and put an ImageView as one of the child, and you can place anything (buttons etc) as other RelativeLayout children. <RelativeLayout ...> <ImageView (your image) ...> <Button (the

Anchor ImageView to Collapsing Toolbar

做~自己de王妃 提交于 2019-11-29 00:40:47
When a FloatingActionButton is anchored to a CollapsingToolbarLayout, it disappears when you scroll up, reappears when you scroll down after a certain point. I was wondering if you can do that with any type of view. In my app, I'm trying to anchor an ImageView to the CollapsingToolbarLayout but it won't disappear like the FloatingActionButton. Here's the XML code. <android.support.design.widget.AppBarLayout android:id="@+id/bar" android:layout_width="match_parent" android:layout_height="252dp" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="

how to get the source of ImageView in order to change it?

不羁岁月 提交于 2019-11-28 23:25:10
I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable) but what I want to do is to check the current ImageSource before changing it. basically, I want to implement my own group radio buttons using imageViews. so every time any imageView is clicked, the oncliked event method will change the Image Resources of my group. and sorry for my poor English. regards, redsea There is no getDrawableId function so you'll need to do something like set a tag for the ImageView when you change its drawable. For instance, set the drawable id as a

Android ImageView ScaleType and item height

↘锁芯ラ 提交于 2019-11-28 23:11:46
Things looked quite simple first but in the end the result is not good. I have an image which has a width larger than screen's width. So I need to scale it down in my imageview. I looked over the ScaleType options and tried them all but none is ok. First "center" only displays the image centered on the layout, no scaling done. "fitCenter" scales the image to fit in my layout but has a major drawback: the height of the item remains as it would have the large image in it. Take a look at the second screen in the attached image. How can I force the list item, to reduce its height to wrap both the

ImageView displaying in layout but not on actual device

别说谁变了你拦得住时间么 提交于 2019-11-28 22:40:06
I have an ImageView that I want to display matching the full width of the device, I realized that like this: <ImageView android:id="@+id/home_bar_newvault" android:layout_width="wrap_content" android:layout_height="40dp" android:scaleType="centerCrop" android:layout_alignParentBottom="true" android:src="@drawable/home_bar" /> The home_bar is a PNG image file with the following dimensions: 2399x254. When I choose to view the Graphical Layout of the UI it displays the imageview correctly at the bottom of the activity. However, when I start the application on my device it won't display the

android imageview 笔记

时光总嘲笑我的痴心妄想 提交于 2019-11-28 22:19:38
android学习笔记34--------------有用代码集(不断更新) 5 人收藏此文章, 我要收藏 发表于3个月前 , 已有 758 次阅读 共 0 个评论 转载请注明原文出处: 奔跑的蜗牛(袁方的技术博客) 点击打开链接 一、当利用textview显示内容时,显示内容过多可能会折行或显示不全,那样效果很不好。今天发现android api中已经给出自动省略的功能。 实现如下: 源码 copy to clipboard 打印 ? <TextView android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:id= "@+id/hello" android:ellipsize= "end" android:singleLine= "true" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/hello" android:ellipsize="end" android:singleLine="true" /> 二、学习]ImageView的scaletype属性 ImageView的属性android:scaleType

Draw round corners on top left top right bottom left bottom right using Path and RectF in Android

戏子无情 提交于 2019-11-28 22:06:45
By making a custom ImageView and override the onDraw method with the following will make the ImageView to have rounded corners. Reference @Override protected void onDraw(Canvas canvas) { float radius = getContext().getResources().getDimension(R.dimen.round_corner_radius); Path path = new Path(); RectF rect = new RectF(0, 0, this.getWidth(), this.getHeight()); path.addRoundRect(rect, radius, radius, Path.Direction.CW); canvas.clipPath(path); super.onDraw(canvas); } How can I selectively make the round corners instead of making all four corners round. For example, only making the top left and

Add text to image in android programmatically

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 21:38:06
I want to make an application just like opening screen of android.I am dynamically adding images to the rows of tableLayout. I have only defined tableLayout in xml file and remaining code is in java. I have added images successfully but i am not getting any help with setting text of that image (I want to display a text under image) and image to be a specific padding.How to do it?Thanks in advance. What you can instead do is to put a TextView in overlay to a ImageView using a RelativeLayout :) Use the following function to write Text on Images: private BitmapDrawable writeTextOnDrawable(int

Transparent GIF in Android ImageView

房东的猫 提交于 2019-11-28 21:30:08
I am trying to display the transparent GIF image in my app with no success. I can get to download and display the icon in an ImageView but with white background instead of transparent. I have already tried these solutions with no sucess: Convert GIF to PNG programatically Has anyone figured out how to display the GIF image with transparency? I am using the Android 18 SDK. Here is a workaround that has worked for me. It is not a good solution. It may not work in all cases and there is significant overhead in image processing. Hopefully someone else will find a better solution. In my testing,

Android add arrow image to spinner

放肆的年华 提交于 2019-11-28 21:19:01
I have created a background drawable that I use for a spinner. I would like to now but an arrow image inside this background. I have tried things like android:drawableRight="arrowimage", but this does not seem to show anything. Does anyone know how I can include an image in my custom background for a spinner? Aniruddha Create an XML in a drawable folder with any name for example spinner_bg.xml and add this following lines <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item> <layer-list> <item> <shape> <gradient android:angle="90"