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

Creating a drawable & zoomable image view in android

Goal: Create an imageview that is drawable and zoomable, That means when I press a button to on , it is drawable, or when I turn off, that is zoomable. *Notice the drawings should zoom align with the…
21
votes
13 answers

Button.setClickable(false) is not working

I have set mButton.setClickable(false); in my code but still this button is invoked by global button.setOnClickListener of my code. EDIT: sorry for the delayed update. Below is the details view where I face the issue. inside my listview…
Pradip
  • 3,189
  • 3
  • 22
  • 27
21
votes
2 answers

How to create a custom View's layout programmatically?

In an Activity, you can create a LinearLayout programmatically in the following way: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout ll = new LinearLayout(this); …
21
votes
3 answers

How to animate a View's translation

At the first click of a button, I want to slide a View along the x-axis (by 200 pixels to the right let's say). And on the second press of the button, I want to slide the View back along the x-axis to its original position. The…
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
20
votes
3 answers

How to display text with two-color background?

I need to create an app for android, where the 2-color text will be displayed on the 2-color background. See picture on the left. Then, the line should be moved with animation and result image should be like on the picture on the right. I have the…
LA_
  • 19,823
  • 58
  • 172
  • 308
20
votes
2 answers

Inflate a view / layout into another layout?

I'm looking for a way to inflate another layout into the first layout in android. How would one do this? Here are the two XML files. The first is the main layout, the second is the layout I would like to inflate into the first. I can't just include…
Kevin Parker
  • 16,975
  • 20
  • 76
  • 105
20
votes
3 answers

Android : How to clip views by parent, like CSS overflow:hidden

I have views as follows :
Relm
  • 7,923
  • 18
  • 66
  • 113
20
votes
4 answers

ListView with triangular shaped items

I need to implement a ListView with triangular shaped items as shown in this image. The views that one adds to a ListView generally are rectangular in shape. Even in the documentation, a View is described as "occupies a rectangular area on the…
Narayan Acharya
  • 1,459
  • 1
  • 18
  • 33
20
votes
4 answers

android.view.InflateException when using selectableItemBackground

When inflating my layout, I get this exception: E AndroidRuntime: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class E AndroidRuntime: at…
EboMike
  • 76,846
  • 14
  • 164
  • 167
20
votes
2 answers

Example usage for ContentLoadingProgressBar

I just found the ContentLoadingProgressBar class from the Android developer site. I searched but couldn't find any usage or explanation for the class. I've listed down a few questions on the class and it would be great if someone answers them. How…
Lalith B
  • 11,843
  • 6
  • 29
  • 47
20
votes
4 answers

Android: LinearLayout addView Animation

I currently have a working Android program that programmatically adds views to a LinearLayout. I would like those views to be animated in and cannot find any good resources on figuring out how to do this. Could someone point me in the right…
20
votes
5 answers

Refreshing a view inside a fragment

I have searched the numerous questions that look like this one, but haven't found my answer in any of them. I have an activity that has 3 tabs accessible through the action bar. I achieved this by adding 3 fragments that inflate a custom view I made…
J. Maes
  • 6,862
  • 5
  • 27
  • 33
20
votes
7 answers

How to add custom view to the layout?

I have a GraphicsView class that extends from the View class and I want to add this GraphicsView class to the main layout in my project. How can I do that? static public class GraphicsView extends View { public GraphicsView(Context context)…
AnasBakez
  • 1,230
  • 4
  • 20
  • 36
19
votes
3 answers

Android - Views overlaid on the last frame of a fullscreen video don't redraw properly when turning the screen on and off

I have a video that plays in portrait mode. At the end of the video, I need to display some views over it. This works fine so far. I am however, having a problem where views that are over the last frame of a video don't redraw properly when coming…
19
votes
3 answers

Change the layout files in the same activity

I am using setContentView(R.layout.main) to switch the views in the same activity. I am calling some asynchronous task and populating the data on the main layout file after that I am changing the view by calling setContentView(R.layout.main)…
madan V
  • 844
  • 3
  • 19
  • 40