android-view

Why do recipes promote overriding getItemViewType and getViewTypeCount when it doesn't seem necessary?

允我心安 提交于 2019-12-21 12:15:46
问题 I've been working through the Commonsware Android Programming Tutorials and in tutorial 5, extra credit 2, the challenge is to use multiple layouts for displaying rows in a ListView depending on the "type name" of the object (a Restaurant's "type" attribute, which is a String). As such, it suggests overriding getItemViewType and getViewTypeCount in a custom ArrayAdapter. In addition, the android docs and other online recipes or blog posts suggest the same. In this situation, following this

How to dim/blur only part of the screen?

流过昼夜 提交于 2019-12-21 12:12:40
问题 I know we can dim/blur the screen, as shown on this post. What should I do in order to dim/blur only a part of it, leaving a single (or multiple) view without any effect, so that the entire screen will have an effect of a highlighted view? Also, will it work even if I make a dialog on top of the current screen, so that the dialog and the highlighted view will remain without any effect? 回答1: I think Showcase View Might be helpful for you. The ShowcaseView library is designed to highlight and

ImageView selectableItemBackgroundBorderless does not render outside of view bounds

孤人 提交于 2019-12-21 09:06:26
问题 I am using selectableItemBackgroundBorderless to add a ripple to an ImageView . My expected behaviour would be to have a circular ripple, extending the views size. Unfortunately the ripple gets cropped by the view bounds. How can this issue be solved? Default state: Pressed state: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/nav_instruction_container" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android

is a view's “tag” restored when the activity whose layout contains the view is recreated?

依然范特西╮ 提交于 2019-12-21 08:17:08
问题 The docs concerning Activity recreation state: By default, the system uses the Bundle instance state to save information about each View object in your activity layout (such as the text value entered into an EditText object). So, if your activity instance is destroyed and recreated, the state of the layout is restored to its previous state with no code required by you. The docs for View.setTag(Object) state: Sets the tag associated with this view. A tag can be used to mark a view in its

Android - Custom dynamically-generated compound View recreated in RecyclerView, causing poor performance

自作多情 提交于 2019-12-21 04:58:33
问题 I'm using a custom CompoundView which extends LinearLayout to display items of a RecyclerView . Each item displays an article which contains multiple paragraphs and images. The CompoundView adds TextView or ImageView dynamically based on the data attached by CompoundView.setData(List<DataPiece> pieces) , the number of which is unknown before data is attached. Each DataPiece object tells CompoundView whether it's a piece of text or an image. And here is the code for CompoundView.setData(List

How to create Clone-Duplicate View?

做~自己de王妃 提交于 2019-12-21 04:36:13
问题 In my android application, I want to create duplicate ImageButton of already created Imagebutton . I want to create new Imagebutton programmatically having same widht, height, background, image src, margins etc. of already created button in XML file. In short, I want to create duplicate ImageButton . I have try this ImageButton mImageButton = (ImageButton) findViewById(R.id.ib); Imagebutton duplicate = mImageButton; But it only refer to the the mImageButton . So, change in duplicate also

Android View onSaveInstanceState not called

[亡魂溺海] 提交于 2019-12-20 18:00:41
问题 I am working with CustomView which extends some Android view like FrameLayout. In my layout I use a ViewPager with a custom PagerAdapter. The problem is that my View did not restore it's state when the fragment is re-attached to the ViewPager/Activity. For example, I have three fragments, if I swipe to the last one and come back to the first, the ScrollView is not where I let it : it's back to default, on top. I know that with a PagerAdapter, not all fragment are active on the same time,

Draw an Android canvas on top of all applications?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 15:42:08
问题 I suspect this isn't possible, given the nature of Android, but is there a way to create a view of sorts (perhaps using a Canvas object?) that is shown on top of all applications? My intent for this project is not malicious. I have created some simple Color Filter software for Windows that simply adds a window on top of all windows, which is filled with a user-chosen color, and has a low opacity. This adds a light tint to the screen which helps users with Scoptopic Sensitivity Syndrome use a

Android nine patch - allow only a specific area of a background drawable to stretch

我怕爱的太早我们不能终老 提交于 2019-12-20 15:10:24
问题 How does one go about creating a View that has boundaries with triangular perforations ? I've been using background drawables to achieve this so far. That works when the dimensions of the View are fixed. Now I have a situation where the height of the View is not constant, so I need to have the height variable on the fly. I can't use a background drawable with a fixed height anymore. Here is the original background drawable: And this is what the final View needs to look like: Another way of

Android nine patch - allow only a specific area of a background drawable to stretch

无人久伴 提交于 2019-12-20 15:09:21
问题 How does one go about creating a View that has boundaries with triangular perforations ? I've been using background drawables to achieve this so far. That works when the dimensions of the View are fixed. Now I have a situation where the height of the View is not constant, so I need to have the height variable on the fly. I can't use a background drawable with a fixed height anymore. Here is the original background drawable: And this is what the final View needs to look like: Another way of