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
1 answer

Is using a TextView to create separation between two page elements ill-advised?

I'm a student in an android development program. I've built a few apps and I had an idea to use a very simple TextView to draw a line across the screen to visually separate a page element. The TextView would hold no text, it has no function or use…
Krausladen
  • 138
  • 10
1
vote
0 answers

How to make an Adapter for a TwoWayView in Android

I am having trouble trying to create an adapter for a TwoWayView from lucasar. https://github.com/lucasr/twoway-view What I want is a facebook-style display for images. Sort of like this. facebook style image structure I am currently trying to…
1
vote
0 answers

How to show error for Custom View in XML Editor

I am developing an open source project. One of the components is a Custom View. I would like to show error in XML editor if some property is missing. Similar to what LinearLayout with multiple views does when orientation is missing.
HBB20
  • 2,743
  • 1
  • 24
  • 35
1
vote
0 answers

Unexpected view on FloatingActionButton

As you can see, there is a strange view on FloatingActionButton compared to the ImageView above. It looks like a ripple effect cause the area open wider when I tap on it. How to remove it? The xml layout…
Hai Hack
  • 948
  • 13
  • 24
1
vote
1 answer

Android (Kotlin) - Cannot access view from another class

I have an Activity Class called MusicPlayer and an external class called MpPlayer. In this latter, my goal is to change the layout from MusicPlayer. However, even though I pass the context from MusicPlayer to MpPlayer, the app continues to return a…
1
vote
1 answer

Making all the buttons have a click sound with minimum code as possible

I have a project with around 100-200 clickable views all of which have OnClickListener. I want to make them play a sound when onClick() method gets fired. I know how to play a sound with MediaPlayer, however, I don't want to write the…
amira
  • 416
  • 1
  • 7
  • 24
1
vote
2 answers

How to transfer data between an Activity and a View class?

I want to transfer 2 float values and 1 boolean value from my MainActivity class to MyCanvas class (which is a class extends View)? Is this possible? I know this a newbie question, but everything that I found told to use Intent and Bundle, or to use…
AndBraz
  • 13
  • 3
1
vote
1 answer

Drop shadow for arcs in canvas

I'm trying to develop a small custom view for my personal project. I'm facing a small trouble as to how to provide elevation effect or drop shadow effect for the view that I created. It is a rectangle with concave semi circles on the left and right…
1
vote
2 answers

Disable click listener for invisible viewgroup

I've a viewgroup which is View.INVISIBLE under some circumstances. In this state, i want the viewgroup or it's children views to NOT respond to any click events. According to the default implementation of View.INVISIBLE in android, the child views…
div
  • 1,475
  • 3
  • 22
  • 32
1
vote
1 answer

ViewOutlineProvider not working with path

I wanna set rounded corner to view with outline, like this fun View.setRoundedCorners(radiusTopLeft: Float, radiusTopRight: Float, radiusBottomRight: Float, …
andreich
  • 1,120
  • 1
  • 11
  • 28
1
vote
1 answer

Constraint layout setting runtime constraintStart_toEndOf

I have a constraint app:layout_constraintStart_toStartOf="parent". Runtime I need to change this constraint to app:layout_constraintStart_toEndOf="@+id\myid" . From my research i found only constraintSet.connect(viewid, ConstraintSet.END,…
1
vote
2 answers

How can I stop my recyclerView view type from changing after scrolling?

Inside my RecyclerView Adapter class I have 2 view types to display the results of my query: @Query("SELECT l.log_id, l.junction_id ,l.date, l.workout_id, l.total_weight_lifted, l.reps, l.set_number FROM log_entries_table AS l…
Josh Brett
  • 77
  • 3
  • 18
1
vote
1 answer

What mechanism causes a View.onSaveInstanceState to be called in Fragment to Fragment navigation?

There is a lot of noise surrounding this subject on SO and Google, so bear with me. When performing Fragment to Fragment navigation, you see this lifecycle: Fragment1: onPause Fragment1: onStop Fragment1: onDestroyView Fragment2:…
Graeme
  • 25,714
  • 24
  • 124
  • 186
1
vote
1 answer

How to put a view in center of activity programatically?

I want to add a custom view programatically over an activity and place it in bottom-center of the activity. So far, I am able to create a view, set its X and Y coordinates and add it to the root view but I am unable to center align the view. Is…
1
vote
2 answers

Dynamic array of views in Kotlin

I am trying to create dynamic TextView by creating an array of TextViews but getting error : java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 My Code: var txtViews = arrayOfNulls(3) for (i in txtViews.indices) { …
Sumit Shukla
  • 4,116
  • 5
  • 38
  • 57