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
1
vote
1 answer

How to apply setColorFilter() with animation?

I have a view, which I want to transform into red color with an animation. I tried to apply a color filter from 00 alpha color to FF alpha color, but when the animation starts, obviously the image it's transparent for the 00 alpha color filter, so…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
1
vote
2 answers

How can an Android activity access the instance if its current View?

How can an activity access the instance of the view, after it's been set using SetContentView? I need this because the activity uses a custom view which includes logic and I need this view to sent events to the activity, through a custom event…
Roland Le Franc
  • 326
  • 1
  • 3
  • 14
1
vote
0 answers

How can I identity if a view has been truncated?

I have the following layout. In the example below, you will notice that Y was not able to be laid out to its full width, and it was cut-off (truncated) due to the lack of vertical space. I would like to be able to programmatically identify when…
ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107
1
vote
2 answers

Scale animation with small "rebound"

I am attempting to use XML Animations to scale a view up from 0% size to 150% size (50% bigger than "real size"). Then scale back down from 150% size to "real size" of 100%. The intention is a bit of a "rebound" effect where the view will grow up…
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
1
vote
1 answer

How to use View.layout() method to change view size?

I have problems doing a small game which adds a lot of views in a ConstraintLayout (I already tested with FrameLayout, RelativeLayout and LinearLayout. First two with same result and Linear with very rare behaviour) and changes the size and position…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
1
vote
1 answer

Databinding on custom View boolean attribute not working

I have a custom view that has a read attribute, defined in xml like this: I get this attribute in the init method of the custom view: read = getBoolean(R.styleable.CustomCardView_read, true) This sets the…
sunilson
  • 1,449
  • 15
  • 31
1
vote
1 answer

Change reading order of elements within a focusable ViewGroup

I have some screens in my app where TalkBack does not infer the correct reading order. According to the documentation, I can use android:accessibilityTraversalAfter and friends to alter the reading order. But it does not work for me for elements…
aha
  • 3,702
  • 3
  • 38
  • 47
1
vote
2 answers

setTranslation is not working on onCreate()

setTranslationY() does not execute translation on a layout in onCreate(), while it's got no problem when used in a setonTouchListener or setOnClickListener. I've also tried animate().translationY(). However the same exact problem appears. I've tried…
elyar abad
  • 771
  • 1
  • 8
  • 27
1
vote
2 answers

Android View.getTag returns null

I have an app where i have 2 buttons in a group which acts like a toggle button. Each button is assigned a static enum in its tag field using data binding as shown below: xml
Mervin Hemaraju
  • 1,921
  • 2
  • 22
  • 71
1
vote
2 answers

Dynamic position of views in RecyclerView

My question is based on a previous question about my Code - it's a newsfeed with different views which are scrollable vertically or horizontally or display various content (ads basically) VERTICAL VIEW HORIZONTAL VIEW AD VIEW Now I managed with…
KayD
  • 372
  • 5
  • 17
1
vote
3 answers

How to make a group of views editable

I have a layout in which there are spinners, editText and checkboxes. There two modes: 1- edit all views (edit mode) 2- view (non edit mode) But I don't want to do it for each view . Is there any way to set editable true or false?
javad ff
  • 75
  • 5
1
vote
1 answer
1
vote
1 answer

Making a View scroll once bottom is reached

Im trying to create a layout with following looks and behaviour. "Contains a couple of texts, most likely LinearLayout"
Basti
  • 1,117
  • 12
  • 32
1
vote
0 answers

Setting the global elevation (z-axis) to a View

Is there any way to set a View's elevation globally regardless of its parent ViewGroup, i.e. relative to the activity's root view? If it can be done with some native code that would be ok too. I have a custom View that needs to show a badge within…
P Fuster
  • 2,224
  • 1
  • 20
  • 30
1
vote
1 answer

How to create an 'Always on top overlay' in Android

I'd started an Android project, and I need to create a small image button that is always on top of all applications. I have seen some other apps doing that, and I want it to be like those. It should be movable in the screen (for example, like…
wsh25
  • 35
  • 7
1 2 3
99
100