How to create TileView on the screen
from the CommonsWare Community archivesAt September 11, 2019, 7:24am, Pvr asked:
I want to know the process of creating Tiles on home screen , could you help me
At September 11, 2019, 10:51am, mmurphy replied:
I do not know what you mean by “Tiles on home screen”, sorry.
Do you mean app widgets? Do you mean launcher icons? Do you mean tiles in the notification shade? Do you mean something else?
At September 12, 2019, 4:25am, Pvr replied:
I have 1 background Image and 1 icon image , I want to insert icon image at a specific part (lower right) of the Background image
Is it possible…
At September 12, 2019, 6:02am, root-ansh replied:
- set rootlayout to framelayout
- Set background to
R.drawable.yourbackground_picture
- add an imageview . set src to
R.drawable.icon_image
- set imageview’s
layout_gravity
asBOTTOM|END
At September 12, 2019, 6:04am, Pvr replied:
is it possible to call all these from Java class file
At September 12, 2019, 6:28am, root-ansh replied:
setting your layout to framelayout is a choice that you have to take in xml only.
Rest all of them can be done by java.
Framelayout root =findviewbyid(R.id.framelayout_xml_id);
root.setbackgroundDrawable(R.drawable.bg);
//if image view is already created in xml and is hidden
Imageview iv =f...i...d(R.id.imageview);
iv.setVisibility(View.VISIBLE);
iv.setImageResourceFile(R.drawable.icon_pic);
Some of the method names might be incorrect/not in proper camelCase format as i am on the phone. Also, if you need to even create the imageview in java, then that is also possible
At September 14, 2019, 11:19am, Pvr replied:
Thank you
I want to know What is Layout Inflater, where and how it can be used .
At September 14, 2019, 11:40am, mmurphy replied:
I cover LayoutInflater
in the books, such as here and here and here. From that third link:
LayoutInflater
knows how to “inflate” layout resources. In Android, “inflate”
means:
Walk a tree of XML elements in an XML resource
Create Java objects for each element in that tree
Stitch those objects together into their own tree structure, mirroring the
tree defined in the XMLReturn the Java object representing the root of the tree
We use it for creating rows/cells/whatever in a RecyclerView
, for loading the contents of fragments in onCreateView()
, etc. Under the covers, things like setContentView(Int)
use LayoutInflater
, even though we do not use it directly there.
At September 16, 2019, 3:46pm, Pvr replied:
I want to know ,
- How to arrange Launcher icons on Home screen as shown in picture(like Matrix form) and
- How to provide Drag and Drop feature for those icons
- I want to give Focus for one icon when nothing is selected
At September 16, 2019, 10:40pm, mmurphy replied:
I would use a RecyclerView
with a GridLayoutManager
.
I would look for a library that might offer that for RecyclerView
.
I have not played with the new-ish recyclerview-selection
library — perhaps you can put something together using that.
At September 17, 2019, 5:04pm, Pvr replied:
But I want image be placed some part out of frame layout
I mean, half inside the layout and half outside the layout , is it possible
At September 17, 2019, 10:44pm, mmurphy replied:
I am sorry, but I do not know what you mean. Note that with a RecyclerView
, you are still in control over what each grid cell contains. Whether that is just an ImageView
, or whether that is an ImageView
in a FrameLayout
, is up to you.
At September 18, 2019, 4:06am, Pvr replied:
Okay
But as you said in the beginning of my question , image view position can be adjusted using gravity - end… "Still I want image position some part out side of the layout "
At September 18, 2019, 10:40am, mmurphy replied:
At this point, I have no idea how to help you further. I apologize for my inability to understand what you want.
At September 19, 2019, 4:53am, Pvr replied:
as shown in pic,
Layout along with image , image goes out of Layout boundary some part
At September 19, 2019, 10:38am, mmurphy replied:
I do not know how this relates to the grid of icons that you asked about previously. If this is a single item in that grid, then that forms a single item in the RecyclerView
.
At September 19, 2019, 1:41pm, Pvr replied:
Okay
For single item , if I take Linear Layout will it (Image view)be visible which is at outside of the layout
And How to give Drag and Drop property to this single item
At September 19, 2019, 9:02pm, mmurphy replied:
You could use the system drag-and-drop techniques that I wrote about in The Busy Coder’s Guide to Android Development.
You could look into handling MotionEvents
yourself, if you wanted. I have not dealt with low-level drag-and-drop like that in several years, so I do not have any current advice. However, there are lots of libraries and samples in the Android Arsenal on dragging views, so some stuff in there may prove useful.