Questions tagged [android-view]

Questions regarding Views in Android. Views may be defined in Android Layout XML or in Java code. Questions using this tag involve general View practices or advice. With regard to specific Views, refer to the info for this tag. For questions regarding layout, use the [android-layout] tag.

Introduction

A View in Android is the display of the data utilized by the application. Views range widely from simple and non-interactive to complex and interactive in many ways. In addition to the Views provided by the SDK, developers have the option to create custom Views. This means that virtually any communication or display to the user may be handled in innumerable ways.

ViewGroups

ViewGroup is a subclass of View, which has the ability to hold other Views. Children Views may be added to the ViewGroup at run-time (in Java code) or may be pre-defined in Android XML. Like Views, ViewGroups may also be extended in the same way. Follow these guidelines for questions regarding ViewGroups:

  • If the ViewGroup is provided by the Android SDK, it should be listed below in Standard Views.
  • If the ViewGroup is a Custom View, use

Standard Views

A wide variety of Views are delivered with the Android SDK for use by developers. These views make up a majority of the Views in a standard application. Each View has its own semantics and behaviors. As a result, it is often more beneficial to use the tags specifically related to those Views. Below is a list of standard views provide within the Android SDK:

Usage: vs.

While Views and layouts work hand-in-hand, questions regarding the two are often very different. These guidelines will help to properly determine which tag to use:

  • If the question refers to the properties used to display the View properly, then use .
  • If, instead, the question refers to the functionality of the View, then is appropriate.
3981 questions
17
votes
3 answers

Android Performance : Adding view programmatically vs setting view to GONE/VISIBLE

I'm working in a project that requires to inflate a simple tutorial View when the user opens the app for the first time. I'm trying to do it "the right way", and I'm wondering about performance issue. Currently, I have in my layout a view sets to…
MagicMicky
  • 3,819
  • 2
  • 37
  • 53
16
votes
3 answers

Infinite scroll of finite items

I have a GridView that has items inside 5x50. I need to scroll them in all directions and instead of stopping when reached the end just start from the top/left. for example left-to-right scroll before scroll 1 2 3 4 5 6 7 8 9 10 after scroll to the…
16
votes
4 answers

Make ImageView have dark transparency

I want to add the transparent black color on top of the image and make it darker.
Karesh A
  • 1,731
  • 3
  • 22
  • 47
16
votes
2 answers

Why we use ViewTreeObserver#addOnGlobalLayoutListener()

Why do we use ViewTreeObserver, please can anyone explain it? In below code creditsView is TextView object. By this whole code I understand that "this is to hide some text based on condition", but only thing is why we are using…
16
votes
4 answers

setRecycledViewPool method in RecyclerView

I am trying to understand what the setRecycledViewPool method actually does along with the RecyclerView in the following line of code where mrecyclerView is a RecyclerView object: mrecyclerView.setRecycledViewPool(new…
16
votes
2 answers

How many WindowInsets are there?

I do not understand about WindowInsets rects, because docs says that: The system window inset represents the area of a full-screen window that is partially or fully obscured by the status bar, navigation bar, IME or other system windows. So,…
GPack
  • 2,494
  • 4
  • 19
  • 50
16
votes
2 answers

Android - difference between offsetTopAndBottom, setTranslateY

Android View seems to have 2 methods which appears to do some very similar functionality. 1] setTranslationX & setTranslationY 2] offsetLeftAndRight & offsetTopAndBottom Can anybody tell me how these are different? What is the scenarion in which [1]…
Androbean Studio
  • 382
  • 2
  • 11
16
votes
3 answers

How to reset ObjectAnimator to it's initial status?

I want to vibrate a view with scaleX and scaleY, and I am doing it with this code, but the problem is that sometimes the view is not correctly reset, and it shows with the scale applied... I want that when the animation ends, the view must be seen…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
16
votes
3 answers

How to set foreground attribute to other non FrameLayout view

I would like to know how to apply or emulate foreground effect in a view different from FrameLayout, as LinearLayout or RelativeLayout This is what I have now:
cesards
  • 15,882
  • 11
  • 70
  • 65
16
votes
6 answers

How can a view detect when it's being attached to its parent?

I have a View that needs to detect when it's being attached to its parent view. In a ViewGroup I have the OnHierarchyChangeListener which allows me to know when a child view is being added / removed, but I need the opposite thing.
user940016
  • 2,878
  • 7
  • 35
  • 56
16
votes
3 answers

How to get screen cordinates corresponding to the whole screen, and not the View touched?

Im having some trouble obtaining the real (x,y) from my screen by handling the touch events of one View Item. I have this: When I touch the View item, it gives me coordinates with the origin located in his upper-left corner, and if i slide the…
Alex
  • 1,449
  • 4
  • 18
  • 28
15
votes
2 answers

XML attributes from merge layout to RelativeLayout via inflate

According to this CommonsWare example I managed to get my RelativeLayout subclass to be merged with my layout described in a xml layout with merge root. My only concern is that I cannot describe my RelativeLayout parameters in xml. My xml…
15
votes
1 answer

Extra space on top and bottom of android Chip material component

I'm using Chip view in my layout Since upgraded material design component from 1.0.0 to 1.1.0, there is an extra space at the top and bottom of view I couldn't find any document about how to remove these spaces In material 1.0.0 In material…
15
votes
6 answers

Full Screen without navigation & status bars

I want to create a activity with full screen. Nothing on above like Notification Bar and nothing below like Home-Button etc.I am able to get this, but also wanted to remove below home-button bar: This is my code.