android-viewgroup

Correctly layout children with onLayout in Custom ViewGroup

末鹿安然 提交于 2021-01-29 03:17:47
问题 I am creating a custom ViewGroup. I does need to have 2 FrameLayout one above the other; the one that stays to the bottom must be 20dp, while the other one must cover the rest of the view. onMeasure @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize

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

How many ViewGroup (LinearLayout, Relative, Grid, etc..) considered too many?

Deadly 提交于 2020-01-05 06:55:13
问题 I tried to find an answer for this specific question but I couldn't. I watched a video https://www.youtube.com/watch?v=NYtB6mlu7vA and I got the impression that over using Layouts generally is expensive. Apps like twitter, use complex designs that consists of many nested group views I realize that these are rows inside a listview, and they are recycled, but my question is, is this considered bad practice generally? The video they discussed the fact that linearlayout performs a calculation to

Passing resource id from Activity to initialize custom ViewGroup

好久不见. 提交于 2019-12-24 13:33:31
问题 This is a followup of my previous question where @pskink adviced me to implement custom ViewGroup that will paint what I need. I succeeded with a prototype using hard coded values. I want to move it to further level where I can pass initialization parameters from an Activity. I need to pass a resource id and open an image to be used in onPaint method. This is the activity. I can get the ViewGroup instance there but it is already instantiated so it makes no sense to pass the resource id in its

How can ExpandableListView's default list item press behavior be preserved when supplying a group view that contains more than just a TextView?

て烟熏妆下的殇ゞ 提交于 2019-12-22 08:40:00
问题 Is it possible to preserve ExpandableListView's default list item press behavior when supplying a group view that contains more than just a TextView. The behavior I'm referring to is where the item being pressed changes background color to yellow. Every time I supply a group view that contains e.g. a TextView and a Button, I lose the behavior. 回答1: Another option is setting your root ViewGroup to block focus for child views. Example: <LinearLayout ... android:descendantFocusability=

ViewPager: java.lang.IllegalArgumentException: pointerIndex out of range

戏子无情 提交于 2019-12-19 04:17:09
问题 I am writing an code to handle touch event based on what suggested here. I am using ViewPager as an ViewGroup and ListView(I know #thisbad) as child view of Fragment. This is what I wanted to achieve: Detect multitouch event on child view then pass touch control to parent but While passing listener event from child View to Parent view it giving following error: E/AndroidRuntime(11414): java.lang.IllegalArgumentException:pointerIndex out of range E/AndroidRuntime(11414): at android.view

Android Adding view from inflate layout and how to update particular textview value in layout

元气小坏坏 提交于 2019-12-13 08:11:42
问题 I have created view from inflating separate layout. I used for loop to create view more than 5 view like an ListView. Here I want call balance check. Inside view, I will click balance button and once receive response from server, I want to update particular TextView in an existing created view. Any help? I am expecting same for phonepe app balance checking page. while scrolling also, it should not hide the updated balance. My Ref stack link: Updating a textview in different layout xml from

BadgeView and SlidingTabStrip clicking error

﹥>﹥吖頭↗ 提交于 2019-12-12 08:16:55
问题 i am using sliding tab from: https://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html and BadgeView from: https://github.com/jgilfelt/android-viewbadger i just add these lines of code to SlidingTabLayout to access each tab: public SlidingTabStrip getTabStrip() { return mTabStrip; } so in fragmenta i can use below code to add badgeview to each tab: public class FragmentA extends Fragment { @Override public View onCreateView(LayoutInflater

Default Style Resource pre API Level 21

佐手、 提交于 2019-12-12 04:23:37
问题 I am looking to create a custom ViewGroup to be used in a library; which contains a few ImageButton objects. I would like to be able to apply a style each ImageButton ; but I cannot figure out how to apply a style programmatically other than by applying a attribute resource to the defStyleAttr parameter; like so: mImageButton = new ImageButton( getContext(), // context null, // attrs R.attr.customImageButtonStyle); // defStyleAttr The issue with this is that the only way to change the style