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
18
votes
2 answers

Use clipping to round corners of ViewGroup

I have a RelativeLayout that needs to have rounded upper left and upper right corners. I can do this with a drawable background defined in XML with corners topLeftRadius and topRightRadius. But... This RelativeLayout also need to have a background…
Neigaard
  • 3,726
  • 9
  • 49
  • 85
18
votes
1 answer

Which is the advantage of using Space over View

I found that I'm using a View to make the space in my layouts and I thought to replace it with a Space. So I asked myself if is there any gain to replace View with Space to make the space. Space using the View widget :
TooCool
  • 10,598
  • 15
  • 60
  • 85
18
votes
2 answers

How to vary between child and parent view group touch events

I decided to post this question and answer in response to this comment to this question: How to handle click in the child Views, and touch in the parent ViewGroups? I will paste the comment here: Suppose I want to override the touch events only for…
user3956566
18
votes
1 answer

How to draw a circle with radial gradient in a canvas?

I created a circle button that can change his color when I call a function. What I want is to create another one, that creates the same circle button but with a radial gradient that starts in the middle with the color selected and that goes to…
Gabriel Esteban
  • 752
  • 2
  • 9
  • 34
18
votes
3 answers

How to set an arbitrary transform matrix to a View?

Since Android 3.0, we have the possibility to set basic 3D transformations to Views using setRotationX and setRotationY, for instance. In a specific case, I would need to achieve a complex transformation that is rotating around a distant pivot point…
DavGin
  • 8,205
  • 2
  • 19
  • 26
18
votes
2 answers

Overriding View.onSaveInstanceState() and View.onRestoreInstanceState() using View.BaseSavedState?

Assume you want to derive your own View class from an existing View implementation, adding a bit of value, hence maintaining a few variables which represent your View's state in a meaningful way. It would be nice if your View would save its state…
class stacker
  • 5,357
  • 2
  • 32
  • 65
18
votes
1 answer

Android Column GridView, variable width like GooglePlus App

So like most we have all used/seen the Google Plus App. What interests me is the ColumnGridView they have developed, which not only does variable width, but variable height, seems that based on content will happily show the best space for the…
Chris.Jenkins
  • 13,051
  • 4
  • 60
  • 61
17
votes
5 answers

How to set a SearchView's input type to numeric

I currently have a SearchView in my app's ActionBar (of which I am populating from an XML layout file) and I am trying to force it to only take numeric input. I've tried setting the android:inputType="number" attribute in XML, but it has no…
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
17
votes
4 answers

Android sidebar like facebook or firefox

With the new facebook app it comes with an hidden sidebar that I would love to use something like that in my applications. It looks kinda like the sidebars that firefox mobile have... Do you have any idea how to implement it besides re-implementing…
17
votes
0 answers

Android keyboard focus losts while going to another view by DPAD

We have 17 api, DPAD control and 4 edittexts in one layout for pin enter. When user try to open something which is locked in the app he faced with fragment where he should enter 4 digits pin. When view is opened we set programmatically view focus to…
17
votes
1 answer

Bottom navigation view with custom item (actionLayout)

I would like to add a custom item in the new BottomNavigationView . There are plenty of tutorial of adding a custom view with the normal navigation view but I can't find anything regarding the bottom one. This is my view …
Manza
  • 3,427
  • 4
  • 36
  • 57
17
votes
3 answers

Possible overdraw: Root element paints background with a theme that also paints a background

I have implemented clickable Recyclerview item and set android:background="?selectableItemBackground" for click effect but while inspecting code I found this lint issue. Lint warning : Possible overdraw: Root element paints background…
Pratik Popat
  • 2,891
  • 20
  • 31
17
votes
3 answers

Android Data Binding - Reference to view

I use in my new app the data binding library of android. Currently I try to pass a reference of another view to a method. I have an ImageButton with an onClickListener. In this onClick listener I want to pass a reference of the root view to the…
Fabian
  • 825
  • 1
  • 8
  • 16
17
votes
2 answers

Android View onSaveInstanceState not called

I am working with CustomView which extends some Android view like FrameLayout. In my layout I use a ViewPager with a custom PagerAdapter. The problem is that my View did not restore it's state when the fragment is re-attached to the…
Hugo Gresse
  • 17,195
  • 9
  • 77
  • 119
17
votes
2 answers

What is android:layout_marginStart

I would like to add some space between the left display border and an ImageView. Android SDK made me aware of "android:layout_marginStart". Consider adding android:layout_marginStart="10dp" to better support right-to-left layouts Why should I use…
null
  • 1,369
  • 2
  • 18
  • 38