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
23
votes
7 answers

java.lang.StackOverFlow error. Suspected too many views?

When you get an error like the one below (Android 1.5), is it because there are too many nested ViewGroups, or because the total number of Views is too great? Are there any tricks to get around it while still keeping the same look to your…
synic
  • 26,359
  • 20
  • 111
  • 149
23
votes
3 answers

Effect of setting parent view visiblity on its children

This question arises from having to show/hide different views dynamicly. View's have 3 visibility settings - visible, invisible, and gone. If you have a parent view, for example a LinearLayout, that has several child views (doesn't matter what they…
Rarw
  • 7,645
  • 3
  • 28
  • 46
23
votes
6 answers

Is there a way to programmatically locate all Windows within a given application?

Is it possible to programmatically enumerate all of the android.view.Windows, or decor views within an application? Dialogs for example will both open in a new Window, separate from the main Activity window. I can locate them via Dialog.getWindow()…
Andrew Lavers
  • 8,023
  • 1
  • 33
  • 50
23
votes
3 answers

Is it possible to manually call onCreateView in a Fragment?

Is it possible to manually call the method onCreateView in a Fragment or, if not, is there some way I can simulate this invocation? I have a FragmentActivity with tabHost. Each tab contains a Fragment and I want to refresh the Fragment's view when I…
Symon_9851
  • 375
  • 1
  • 3
  • 9
23
votes
4 answers

Android Imageview fill the screen width

Here my layout file:
tsil
  • 2,069
  • 7
  • 29
  • 43
23
votes
3 answers

How to Measure TextView Height Based on Device Width and Font Size?

I am looking for method in Android that will take a input (text, text_font_size, device_width) and based on these calculations it will return how much height will required to display particular text ? I am setting a text view/ webview height runtime…
Mac
  • 1,153
  • 2
  • 20
  • 34
23
votes
7 answers

Detect touch event on a view when dragged over from other view

How do I detect the touch event if the user touches on view A and drags to bottom over the view B. I want to detect the touch event in View B. I added touch listener in view B but doesn't receive events if the user initially touched A and dragged…
dcanh121
  • 4,665
  • 11
  • 37
  • 84
23
votes
3 answers

Fragment - removeGlobalOnLayoutListener IllegalStateException

I'm trying to get the height and width of an ImageView in a Fragment with the following ViewTreeObserver: import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; private ImageView…
float
  • 1,265
  • 5
  • 22
  • 38
23
votes
4 answers

In gridview adapter, getView(position == 0) was invoked too many times to measure layout when setImageBitmap() in a loader

I have a GridView for showing some icons. BEFORE I had read this Displaying Bitmaps Efficiently from Android developer site, I was decoding bitmap from local path directly in getView() of adapter, like this : public View getView(int position, View…
raywang
  • 455
  • 1
  • 4
  • 9
22
votes
4 answers

sliding one fragment over another in Android

In android, can we slide a fragment over another? For example, in the following image : There are two fragments. One is red colored, and the other blue colored. If the user presses his finger on the black colored arrow and drags it to the right,…
22
votes
3 answers

Get rid of unnecessary root layouts for fullscreen activities

How to get rid of unnecessary root layouts for fullscreen activities? I have a simple fullscreen activity. The layout inspector shows a large hierarchy of root layouts provided by Android, that I don't need in fullscreen. Can I get rid of…
Blcknx
  • 1,921
  • 1
  • 12
  • 38
22
votes
6 answers

Using new IMMERSIVE mode in android kitkat

I want to make an activity to go into IMMERSIVE mode and hide top and buttom system bars as soon as it starts. In developers site of android they say I should use setSystemUiVisibility() and provide SYSTEM_UI_FLAG_IMMERSIVE and…
Dumbo
  • 13,555
  • 54
  • 184
  • 288
22
votes
1 answer

Implementing pinch zoom and drag using Android's build in gesture listener and scale listener

I am trying to implement pinch zoom and drag using Android's gesture listener and scale listener. The problem is that when I perform pinch zoom, the image (which I am trying to zoom) bounces to a particular location. Also the zoom position is not…
21
votes
8 answers

OnTouch works, but OnClickListener doesn't?

I created a widget/control that I can reuse which I created by extending RelativeLayout. Then, in one of my Activities, I created a bunch of these widgets in a loop. However, I ran into an issue when I wanted to have each widget respond to a…
tpow
  • 7,600
  • 11
  • 59
  • 84
21
votes
10 answers

Check if fragment is currently visible or no

I know there are lots of similar questions in StackOverflow but my question is little different. I have nested hierarchy of Fragments like in below structure: Activity | …
Viks
  • 1,510
  • 4
  • 22
  • 50