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

How to Preview SciChartSurface in Compose?

I’d like to preview SciChartSurface in Compose using @Preview annotation. I am getting error java.lang.NoClassDefFoundError: Could not initialize class com.scichart.drawing.canvas.RenderSurface$d @Composable fun MyAndroidViewPreview() { val…
1
vote
0 answers

How to apply theme to text in AndroidView in Jetpack Compose app

Please, how do I get text color of html string formatted with AndroidView() to change as the application theme changes programmatically from Light to Dark theme and vice-versa? Thanks in advance! Below are my codes: Compose Function …
1
vote
1 answer

Jetpack Compose with WindowManager - Cannot start this animator on a detached view

I am currently working on an Android library called Floating-Bubble-View, this library helps create a floating view on the screen. Recently, I added support for Composable and with the help of a custom LifecycleOwner, I can show/remove the…
1
vote
0 answers

Kotlin - Show error message when data is null

I'm trying to make an app that gets data from TMDB API with retrofit. I use Paging Source and Flow to get the movies from the api. MoviesViewModel.kt class MoviesViewModel: ViewModel() { val isLoading: MutableLiveData =…
t3nsa
  • 680
  • 6
  • 21
1
vote
0 answers

How to access the main activity's view from a custom widget?

I have a custom "view" widget (CustomController) on my application's main screen. In the widget's constructor, I can access an image in the widget's xml file with the following code: (Note, img_cursor is an ImageView in…
1
vote
4 answers

How to make sure I use the same instance of the ViewModel?

In the MainActivity I create a ViewModel object using: class MainActivity : ComponentActivity() { private val viewModel by viewModels() override fun onCreate(savedInstanceState: Bundle?) { …
Joan P.
  • 2,368
  • 6
  • 30
  • 63
1
vote
1 answer

How to hide previously displaying overlay view when new overlay view comes for display using Window Manager in android?

I am displaying one overlay view using Window Manager on incoming or outgoing call. When I receive one call my overlay window appears on screen but when I receive another call overlay window appears again on the previous displayng window and so…
1
vote
1 answer

Disable smooth resize to make Android app fully compatible with Windows Subsystem for Android

My app needs to perform some view resizing after the layout is done. It's currently done in onWindowFocusChanged(). It's not working as intended on Windows 11 (using Windows Subsystem for Android, WSA). During manual window resizing, the Activity…
Sébastien
  • 13,831
  • 10
  • 55
  • 70
1
vote
0 answers

Programmatically created views in Android do not inherit the theme specified in the manifest file

I have a project with the theme defined in the manifest file. When I use XML to define the views, the theme is inherited and applied, however when I create the views programmatically, no theme is applied. How do I get the theme defined in the…
Hendré
  • 262
  • 10
  • 27
1
vote
0 answers

Exoplayer2 never sending rtsp fetch

I am trying to fetch and display rtsp data from my localhost. Fetching api data through 10.0.2.2 did work , but fetching the RTSP stream that is run locally through docker. Isn't receiving calls from this code: val mediaSource: MediaSource =…
Iets Iets
  • 47
  • 6
1
vote
0 answers

I want to reverse the rounded corner in Android kotlin

I have tried with layerlist but don't know which syntax can help me to implement my desired shape.
Pankaj Sah
  • 11
  • 1
1
vote
1 answer

Identify first visible view inside viewgroup

I have several TextViews inside ConstraintLayout. The visibility of those TextViews are set at runtime based upon the data availability. I need to bold the text of the first visible TextView. I have tried many things but couldn't resolve the…
skafle
  • 627
  • 1
  • 6
  • 16
1
vote
0 answers

Android can't access width of dynamically added view

I am adding some EditText views programmatically to a LinearLayout and for some reason I am not able to adjust the width of these EditText views. the goal I am trying to accomplish is have all the EditText views be of the same width, and that width…
1
vote
1 answer

Android view Factory cannot detect the correct height of TextView in jetpack compose

I'm using jetpack compose, and I need to show HTML text. Since the compose Text function doesn't support this functionality, I use the AndroidView factory to load my HTML inside a TextView: AndroidView(factory = { context -> …
1
vote
0 answers

How to force layout of a view hierarchy in Android+RN+Google Ad SDK

We have an infuriating situation with what are called "fluid ads" on Android in a React Native app. Basically the React Native layout infrastructure and the Google Ads Android infrastructure do not play nice. We have hacked it up enough such that we…
Max Metral
  • 261
  • 3
  • 12