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
0 answers

Dynamically added Views in RecyclerView duplicate uncontrollably every time scrolled in and out the screen

My project is making a Quiz app using Recycler View. Single view layout is a LinearLayout with one TextVIew showing quiz question, code as below:
1
vote
1 answer

initliaze and use viewbinding views by kotlin lazy delegate making view making view not inflate properly after first inflate

So i am migrating my code from Kotlin Synthetic to ViewBinding but when i write ViewBinding code its so much boilerplate like the first assign all views as lateinit var to use them in the whole class and then initialize these views in onViewCreated…
Burhan Khanzada
  • 945
  • 9
  • 27
1
vote
0 answers

Where can I find that AlertDialog.Builder.setItems has a return type -> dialog, which?

I visit a Tutorial and there was this code: pictureDialog.setItems(pictureDialogItems) {dialog, which -> when(which) { 0 -> Toast.makeText(this@Test, "Gallerie auswahl kommt noch", Toast.LENGTH_LONG).show() 1 ->…
1
vote
0 answers

How to set backgound in linechart of MP Chart library android?

I want to know is it possible to set background like this in MP chart library's Line chart like this, only in the graph area: I tried lineChart.background = ContextCompat.getDrawable(requireContext() , R.drawable.ic_graph) but it applied…
Rahul Pawar
  • 403
  • 3
  • 13
1
vote
1 answer

How to reverse View Binding from custom tab layout in Android?

I made a custom tab item for my tab layout and initialized it using view binding as follows: val tabView = CustomTabBinding.inflate(LayoutInflater.from(mContext), null, false) tabView.tvCustomTabTitle.text = it.title …
1
vote
1 answer

Fake data to preview custom view

I'm writing custom view for charts. How does I can to pass fake data into view, when it is in edit mode? (I know about isInEditMode, but when I'm trying to pass data inside init block it crash preview) That will be without any code in init (and you…
1
vote
3 answers

ViewCompat.setOnApplyWindowInsetsListener don't take affect when it take view as atribute

I try to handle insets by setting ViewCompat.setOnApplyWindowInsetsListener on attached view, but listener is not called. I'm confused, because when i apply insets listener to decorView, it works: …
KirstenLy
  • 1,172
  • 3
  • 14
  • 25
1
vote
1 answer

Using CheckBox's with button and switch

I am trying to show toast with the color name of the CheckBox that selected, but when I click on the button, nothing happens, I tried to use the LinearLayout as a parent of all views to get the id of the chosen Checkbox, first I tried to create it…
1
vote
1 answer

Is View.generateViewId() unique across libraries?

If I use myView.setId(View.generateViewId()) (View.generateViewId()) in multiple libraries, is it guaranteed to be unique across all libraries or is the value only guaranteeed to be unique in each library itself?
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
1
vote
1 answer

Clip For GradientDrawable.setCornerRadii not working

I'm trying to create a view with custom radius but facing a problem when using GradientDrawable.setCornerRadii...Line If i use Below code the view clips all the child view inside it public void SetCornerRadius(View v,int Radius){ …
1
vote
3 answers

Android EditText use the entire activity height after title

I am developing an android app to support posting articles by the user and have an EditText for the same and below is my layout.
1
vote
1 answer

How to make a line in android that is stretchable, moveable, and rotatable such as this one found in Lucidchart

I'd like to make a line over an ImageView that is editable. Preferably like this one from lucidchart. Is there any Android widget that can accomplish such task?
1
vote
0 answers

Detect when ScrollView frame is clicked

I create frames like this. The number can change throughout runtime. for (i in (1..numStations(serverText)))// number of frames { frame = ScrollView(this@HomeActivity) layoutInflater.inflate(R.layout.frame_layout, frame) frame.tag =…
GeoCap
  • 505
  • 5
  • 15
1
vote
2 answers

Spannable text that holding custom view

Is that possible to add a custom view into a spannable text? In android.text.style package I can see many types of spannable objects, but I wonder if I can add a custom view. Sort of spanable.setSpan(CustomView, .. , .. ,..) Note that: CustomView…
Ibrahim Ali
  • 1,237
  • 9
  • 20