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
0 answers

Android adding custom Interpolator to Animation prevents the animation from getting cancel

I have extended the Animation class to show circle being drawn as animation here is my Animation class public class CircleAnimation extends Animation { private Circle circle; private float oldAngle; private float newAngle; public…
1
vote
1 answer

Why won't my LayoutParams change my layout?

I want to display a box with suggested entries next to an EditText. I figured I'd have to set LayoutParams (like suggested in this question. However, no matter what I try, the box always ends up in the top left corner. What I tried: - get…
Joozd
  • 501
  • 2
  • 14
1
vote
3 answers

Item's shadow inside a ViewPager2 is clipped

I have an activity that has a NavHostFragment. This NavHostFragment will host three fragments, two of which are FragmentA and FragmentB. Inside FragmentB, I have a ViewPager2 which has two pages: PageA and PageB, both are actually constructed from…
1
vote
2 answers

Custom view with canvas draw in Recyclerview not working

I'm trying to draw an arc from one view to another (canvas drawing) inside recyclerview. So I added a custom view in recyclerview layout. But it's not getting drawn properly. It draws randomly for some items in recyclerview. Here's my code…
1
vote
2 answers

Animation not working in onLongClickListener

I have a simple scale animation: val x = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 2f) val y = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 2f) val grow = ObjectAnimator.ofPropertyValuesHolder(imageViews[j].starViews[3], x, y).apply { …
Lucas
  • 87
  • 1
  • 8
1
vote
2 answers

Is there a way to observe when a method from another class is called?

I want to have a custom keyboard class that has different buttons. This class will implement the onClick listener when each button is called but I want another class to handle this event. For example: class Keyboard { Button A Button B ... …
nicoqueijo
  • 872
  • 2
  • 11
  • 28
1
vote
2 answers

Is initializing a new RecyclerView Adapter an asynchronous call?

My question is, is the initialization of a new RecyclerView adapter an asynchronous call? I have an adapter that I am creating: mRecyclerAdapter = new TestAdapter(mContext,…
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
1
vote
1 answer

withEndAction doesn't always trigger

I have a problem with the "View.animate().withEndAction()" function in Android. Most of the time the code below works perfectly, animation is fine etc. But in about 5% of the cases, "// doSomething1 " isn't executed. But I've never experienced a…
1
vote
1 answer

Why doesn't RequireView() not return a view onResume()?

I'm parsing data with a Volley Request on the onResume() method of my fragment, to populate the layout with the parsed data I need to get the view of my fragment, that's why I'm calling requireView() onResume() after a successfull parsing. For the…
KayD
  • 372
  • 5
  • 17
1
vote
2 answers

KOTLIN : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views

I have this code: lifecycleScope.launch(Dispatchers.Default) { val specialMessage = URL("https://finepointmobile.com/api/inventory/v1/message").readText() d("Globby", "The message is: $specialMessage") …
Globby
  • 51
  • 2
  • 8
1
vote
3 answers

Using Observable Boolean to set visibility of an android view

This is regarding something quite trivial that I have been fighting over in a code review. The scenario is such. There is a data binding layout:some_layout.xml, backed by a ViewModel. [contents ofsome_layout.xml ]
Som
  • 83
  • 2
  • 9
1
vote
1 answer

Are Android Views backed by OpenGL?

Do native Android views (View class and everything that extends it, i.e. TextView, ImageView, etc...), use OpenGL under the hood? If not, are there any advantages to using OpenGL to the average Android Developer as opposed to using the regular…
1
vote
1 answer

How to display all hidden checkoboxes in a recyclerview on long press?

I made a layout for an item, with a hidden checkbox. On a long press, I want to make all checkboxes for all item in the recyclerview visible. I've tried to implement a long click listener but on a long press of an item only the check box for this…
dudi
  • 5,523
  • 4
  • 28
  • 57
1
vote
1 answer

Android - Custom view text color Selector

I created a custom view which contains a TextView inside and at some point I will need to change the text colour. Using a standard declare-styleable with works.
TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50
1
vote
2 answers

How to simply create a custom view without duplicate LinearLayout?

The simplest way I found to create a custom view, so I don't have to handle annoying things like to override the onLayout() method, is to make it inherit from a LinearLayout. I also have a LinearLayout at the root of the associated XML file that I…
Bencri
  • 1,173
  • 1
  • 7
  • 22