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
27
votes
4 answers

How to inflate multiple instances of a layout with the same id inside an inflated layout

I have a LinearLayout with many nested LinearLayouts and TextViewss My main activity inflates the main LinearLayout, Then I load data from a server and based on the data received, I add multiple Layouts in a place holder (LinearLayout) This is…
Shehabic
  • 6,787
  • 9
  • 52
  • 93
25
votes
1 answer

Align FrameLayout inside ConstraintLayout to bottom

I want a layout above recycler view at the bottom of the screen,(like a frame) so that even when that layout is visible I can still scroll recycler view behind it. So I want to align the frame layout at the bottom of the screen and make it visible…
Pritish
  • 1,284
  • 1
  • 19
  • 42
25
votes
2 answers

Create UI like Chrome for Android

I want to implement this behaviour [https://github.com/gleue/TGLStackedViewController] in an app that I am trying to make. The closest thing/the effect that I want to achieve is how the Google Chrome browser behaves. Tile/card interface Be able to…
momoja
  • 938
  • 9
  • 23
25
votes
1 answer

filling a circle gradually from bottom to top android

I have created a circle with a stroke and white background using xml. How can this be filled gradually from bottom to top on user actions(e.g. on successive button press)? Is there any free library which can be used to achieve similar thing?
Kaps
  • 2,345
  • 2
  • 26
  • 37
25
votes
3 answers

How to change the current tab highlighter color in Android ViewPager?

Here is my layout inside ViewPager. I would like to change the color of the current tab highlighter which is below the text. Actually it is showing in black color. But I don't know whether it is a color by default or not. And also I have one more…
intrepidkarthi
  • 3,104
  • 8
  • 42
  • 75
25
votes
3 answers

Is there a way to offset a view from center?

I'm trying to possition my button not exactly in center, but let's say in the 2/5s of the screen height, I was looking for attribute unsuccessfully, so I tried this approach
urSus
  • 12,492
  • 12
  • 69
  • 89
24
votes
6 answers

How to half overlap images in android constraint layout

Is there any way to place an images half is on top of another image using only constraint layout. I know it can be done using relative and frame layouts but in the case of constraint layout is there anyway? prefer ways which do not require any…
24
votes
4 answers

Android: How to test a custom view?

There are several methods of unit testing in Android, what's the best one for testing a custom view I've written? I'm currently testing it as part of my activity in an instrumentation test case, but I'd rather test just the view, isolated.
futlib
  • 8,258
  • 13
  • 40
  • 55
24
votes
3 answers

Getting position of View in onCreateViewHolder

I am using a RecyclerView with a single row layout with an ImageView and a TextView. I want to implement a OnClickListener for the View and not for seperate ViewHolder objects. How can i get the position of the view in the Adapter? Right now i'm…
24
votes
3 answers

Different fling (swipe) velocity on different Android devices with same density

I'm writing my own image viewer that enables users to swipe left\right to see the next\previous image. I want to animate the image change according to the fling velocity. To detect a fling gesture and its velocity, I followed this basic gesture…
Ron Tesler
  • 1,146
  • 1
  • 11
  • 24
24
votes
1 answer

Android Views: can checking visibility before setting visibility improve performance?

I have helper methods that set the visibility of certain Views depending on the state variables that are passed into the methods. Sometimes, these methods will get called many times and the Views visibility will not change. So I found myself…
Steven Byle
  • 13,149
  • 4
  • 45
  • 57
23
votes
4 answers

Achieve toolbar menu item click ripple effect

I try to use padding to increase the touch area of a button. I use
23
votes
1 answer

How to make Twitter app style Quick Actions on Android

Is there any code that gives an example about how to implement the Quick Actions and Popdown menu that is displayed in the Twitter for Android app?
Rich Schuler
  • 41,814
  • 6
  • 72
  • 59
23
votes
2 answers

Custom ViewGroup focus handling

Let's say I have a custom ViewGroup which is focusable and has some child views which are focusable as well (A custom vertical menu for Android set-top-boxes which should react on remote controller). I need to pass a focus to some of the child…
traninho
  • 1,533
  • 12
  • 19
23
votes
2 answers

Android: can you have a ripple effect whose default state color is transparent?

Something like the following, but it doesn't work. If I switch the drawable color to something like blue, it works.
ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107