onmeasure

When is View.onMeasure() called?

孤街浪徒 提交于 2019-12-30 02:37:10
问题 When is View.onMeasure(int widthMeasureSpec, int heightMeasureSpec) called? I have an Activity that needs to perform an action after onMeasure has been called. My question is the same as the unanswered question posted here. The View documentation states that onMeasure is called when requestLayout() is called, which is apparently called by a view on itself when it believes that is can no longer fit within its current bounds. However, this doesn't tell me when my activity can assume that my

Android View resize and WindowManager: unwanted transition during child view placement

夙愿已清 提交于 2019-12-25 18:14:39
问题 I'm having some problems in avoiding an unwanted transition during child view placement in a custom ViewGroup after parent view resizing. This problem seems to be only present when using the WindowManager instead of the call to setContentView() . Here is a short example: MainActivity : public class MainActivity extends AppCompatActivity { private static final int MY_PERMISSIONS_DRAW_OVER_OTHER_APPS = 1; CustomViewGroup mCustomViewGroup; WindowManager mWindowManager; @Override protected void

android gridview header solution with adapter recycling cells

限于喜欢 提交于 2019-12-21 05:57:23
问题 I've seen many solutions about how to implement a gridview header that scrolls along with the rest of the grid. Most of them consist in creating a listlayout or relativelayout with a header view and a gridview all inside a scrollview. This solution has the problem that the scrollview doesn't know the size of the grid so to overcome that you need to extend grid view like here: https://stackoverflow.com/a/4536955/751180 But the problem is that but doing so you are forcing the gridview to render

android gridview header solution with adapter recycling cells

被刻印的时光 ゝ 提交于 2019-12-21 05:57:15
问题 I've seen many solutions about how to implement a gridview header that scrolls along with the rest of the grid. Most of them consist in creating a listlayout or relativelayout with a header view and a gridview all inside a scrollview. This solution has the problem that the scrollview doesn't know the size of the grid so to overcome that you need to extend grid view like here: https://stackoverflow.com/a/4536955/751180 But the problem is that but doing so you are forcing the gridview to render

Custom Button background is being drawn wrong (sometimes)

ε祈祈猫儿з 提交于 2019-12-13 20:52:32
问题 I have this custom button, which does not draw himself and has no child views. Right after app launch it looks like this: At this point I don't know what code and details might be relevant for posting here. The fact is after the app changes state the button checks whether to stay VISIBLE or go INVISIBLE . It remains VISIBLE . It calls setVisibility(View.VISIBLE) and after that, when the screen shows again, it looks like this: If I click the button it returns to be fine with its original

How to get width and height of resized custom view , before it is drawn

↘锁芯ラ 提交于 2019-12-13 19:43:11
问题 In my custom View .xml , i have defined width and height as w = 600dp , h = 700dp . Now i know getMeasuredHeight() / getMeasuredWidth() give values of width and height after view is drawn and they may differ from what i've given in .xml file , is there a workaround to get getMeasuredHeight() and getMeasuredWidth() values before view is actually drawn on layout, without use of onMeasure() ? And How to calculate changed dp sizes in different screens ? like my 600h*700w when run on emulator

android--------自定义控件 之 方法篇

痴心易碎 提交于 2019-12-10 07:41:02
前面简单的讲述了Android中自定义控件的理论和流程图,今天通过代码来详细的讲解一下其中的方法 首先先创建一个类 CircularView 继承于 View,之后实现构造方法(初始化步骤) public class CircularView extends View { public CircularView(Context context) { super(context); } public CircularView(Context context, AttributeSet attrs) { super(context, attrs); } public CircularView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public CircularView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } } View的构造函数有四种重载,View构造函数的参数有多有少, 有四个参数的构造函数在API21的时候才添加上

Android: Listview in ScrollView with dynamic height

纵饮孤独 提交于 2019-12-08 10:26:37
问题 currently I am developing a settings menu in a scrollview. The basic structure looks like the following: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:id="@+id/scrollview_settings" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="@dimen/paddingSmall"> <LinearLayout android:layout_width="match

Android View系统解析(下)

拟墨画扇 提交于 2019-12-04 18:19:32
转载请注明出处: http://blog.csdn.net/singwhatiwanna/article/details/38426471 (来自singwhatiwanna的csdn博客) Android View系统解析系列: Android View系统解析(上) 介绍View的基础知识、View的滑动、弹性滑动、滑动冲突解决方式、事件分发等 Android View系统解析(下) 介绍View的Framework层原理、View的measure / layout / draw三大流程和一些高级技巧 本次主要介绍下半部分,提纲如下 View的绘制过程 measure/layout/draw 工作流程 识别 MeasureSpec 并能够 make 合适的 MeasureSpec 在渲染前获取 View 的宽高 构造特殊的 View 自定义View 自定义View分类 自定义 View 须知 一 View的绘制过程 初识 ViewRoot ViewRoot 对应于 ViewRootImpl 类,是连接 WindowManager 和 DecorView 的纽带。 ActivityThread 中当 activity 对象被创建好后,会将 DecorView 加入到 Window中同时完成 ViewRootImpl 的创建并建立和 DecorView 的联系。 root =

android gridview header solution with adapter recycling cells

久未见 提交于 2019-12-03 21:24:20
I've seen many solutions about how to implement a gridview header that scrolls along with the rest of the grid. Most of them consist in creating a listlayout or relativelayout with a header view and a gridview all inside a scrollview. This solution has the problem that the scrollview doesn't know the size of the grid so to overcome that you need to extend grid view like here: https://stackoverflow.com/a/4536955/751180 But the problem is that but doing so you are forcing the gridview to render all the items at once without recycling its cells. This will probably cause the app to crash due to