android-view

Why we use ViewTreeObserver#addOnGlobalLayoutListener()

こ雲淡風輕ζ 提交于 2020-08-24 07:29:32
问题 Why do we use ViewTreeObserver , please can anyone explain it? In below code creditsView is TextView object. By this whole code I understand that "this is to hide some text based on condition", but only thing is why we are using ViewTreeObserver ? mainLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int heightDiff = mainLayout.getRootView().getHeight() - mainLayout.getHeight(); if (heightDiff > 100)

What is android:layout_marginStart

家住魔仙堡 提交于 2020-07-17 09:49:22
问题 I would like to add some space between the left display border and an ImageView. Android SDK made me aware of "android:layout_marginStart". Consider adding android:layout_marginStart="10dp" to better support right-to-left layouts Why should I use android:layout_marginStart="10dp" instead of android:layout_marginLeft="10dp" ? I have never done so and never encountered any problems with so-called "right-to-left layouts". 回答1: start and end are the same as left and right for left-to-right (LTR)

Are Android Views backed by OpenGL?

♀尐吖头ヾ 提交于 2020-06-17 09:10:47
问题 Do native Android views (View class and everything that extends it, i.e. TextView, ImageView, etc...) , use OpenGL under the hood? If not, are there any advantages to using OpenGL to the average Android Developer as opposed to using the regular views for custom UI components? 回答1: Do native Android views (View class and everything that extends it, i.e. TextView, ImageView, etc...), use OpenGL under the hood? Basically yes, OpenGL ES is the API used by the display hardware system to draw

Are Android Views backed by OpenGL?

随声附和 提交于 2020-06-17 09:10:46
问题 Do native Android views (View class and everything that extends it, i.e. TextView, ImageView, etc...) , use OpenGL under the hood? If not, are there any advantages to using OpenGL to the average Android Developer as opposed to using the regular views for custom UI components? 回答1: Do native Android views (View class and everything that extends it, i.e. TextView, ImageView, etc...), use OpenGL under the hood? Basically yes, OpenGL ES is the API used by the display hardware system to draw

setRecycledViewPool method in RecyclerView

无人久伴 提交于 2020-05-07 19:20:27
问题 I am trying to understand what the setRecycledViewPool method actually does along with the RecyclerView in the following line of code where mrecyclerView is a RecyclerView object: mrecyclerView.setRecycledViewPool(new RecyclerView.RecycledViewPool()); I read the Android documentation link and I still don't understand what it does clearly. Can someone explain to me its use and when to use it? 回答1: setRecycledViewPool(...) can be useful when we have a nested RecyclerView. See this blog post for

Repeatedly altering visibility of a child view and measuring parent view causes wrong results in measured size and display

做~自己de王妃 提交于 2020-04-10 18:10:53
问题 Why is it that when you repeatedly alter the visibility of a child view that is contained within a parent view and measure the parent view, Android returns wrong results? I created a simple test: an XML file with only one ConstraintLayout and two TextViews. I will repeatedly alter the visibility of the last TextView to GONE and VISIBLE. Each time I alter the visibility of the TextView, I will measure the ConstraintLayout's width and height. To alter the visibility of the TextView, I set a

Repeatedly altering visibility of a child view and measuring parent view causes wrong results in measured size and display

此生再无相见时 提交于 2020-04-10 18:09:52
问题 Why is it that when you repeatedly alter the visibility of a child view that is contained within a parent view and measure the parent view, Android returns wrong results? I created a simple test: an XML file with only one ConstraintLayout and two TextViews. I will repeatedly alter the visibility of the last TextView to GONE and VISIBLE. Each time I alter the visibility of the TextView, I will measure the ConstraintLayout's width and height. To alter the visibility of the TextView, I set a

What does top, left, right and bottom mean in Android Rect object

↘锁芯ラ 提交于 2020-04-07 10:49:46
问题 I have an Android project where I should make Apples fall. The apples are painted in a Rect. So I created a function that change the Rect position and repaint. Here's my function : private void updateApplesPosition() { for(Rect rect:fallingDownFruitsList) rect.set(rect.left, rect.top +10, rect.right, rect.bottom +10); } I have a problem : the Apples don't fall but go from right to left. To make the apples fall I changed the code by this : private void updateApplesPosition() { for(Rect rect

Does BadgeDrawable not work for views within a FrameLayout such as buttons, images, textviews etc.?

我们两清 提交于 2020-03-24 11:10:52
问题 I have this function in my main activity which doesn't display a badge: private fun setFindShiftBadge(state: HomeState) { val findShiftsBadge = BadgeDrawable.create(this) home_framelayout.foreground = findShiftsBadge findShiftsBadge.badgeGravity = BadgeDrawable.TOP_END findShiftsBadge.backgroundColor = resources.getColor(R.color.colorWhite) findShiftsBadge.badgeTextColor = resources.getColor(R.color.colorPrimary) findShiftsBadge.number = state.availableShifts.size } In the same activity, I

View not attached to window manager (whats the solution?)

纵然是瞬间 提交于 2020-03-14 07:40:38
问题 I got hundreads of error reports from my app and all of them is the same. It is really annoying because in my test devices (HTC Wildfire, Galaxy S I-II-III, Galaxy Mini, Galaxy Tab 10) this error NEVER occured, neither to me or my test buddy, looks like users do something different then us. Because of this i cant give you too much information about the situation, there is one thing i see, it is something with a dialog's dismiss, which i actually never calls by code. here is the error: java