android-view

Android - listener after redrawing on invalidate()

守給你的承諾、 提交于 2019-12-22 09:39:07
问题 I'd like to be notified after the view finishes redrawing after I ask it to invalidate. As said in this answer, the invalidate() method doesn't call a View's onDraw() the UI immediately, but schedules the repaint in a message queue which is executed after when the main thread is idle. I'd like to show a progress dialog, do some UI modifications and then dismiss the dialog when the view is drawn properly. Is there some trick that I can do to know when the View was drawn? Maybe by subclassing

When do we know when an Activity's views have been layed out

拜拜、爱过 提交于 2019-12-22 08:25:40
问题 I have an Activity with a view hierarchy as follows: <RelativeLayout> <LinearLayout> <GridLayout /> </LinearLayout> </RelativeLayout> The top RelativeLayout takes up the full screen while the LinearLayout takes up a subset of the screen. I'm trying to set the size of the children views of the GridLayout in such a way that with n rows and m columns the size of cells is directly related to the n,m values and the width and height of the LinearLayout. So for example, I'm trying to get the cell

View Gone when clicked outside that view

和自甴很熟 提交于 2019-12-22 06:48:33
问题 I wanted to hide the view when clicking outside that view, for example, <Framelayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" > <fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> <ImageView android:id="@+id/imgButtonToOpenGrid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout

Android: fitsSystemWindows and newline interfering with bottomSheets

戏子无情 提交于 2019-12-22 06:25:20
问题 I have found out that if the parent layout contains android:fitsSystemWindows="true" , it will interfere with my BottomSheets positioning, when a view-related action happens. Specifically the one I'm encountering: where a newline in a textview will trigger the bottomsheets to offset by the height of the system/notif-bar. newline + fitsSystemWindows = shoves my bottomsheet down I eliminated all irrelevant stuff down to buttons, textview and the bottomsheet. Button2: setText("1\n2") is where

Android: fitsSystemWindows and newline interfering with bottomSheets

 ̄綄美尐妖づ 提交于 2019-12-22 06:25:06
问题 I have found out that if the parent layout contains android:fitsSystemWindows="true" , it will interfere with my BottomSheets positioning, when a view-related action happens. Specifically the one I'm encountering: where a newline in a textview will trigger the bottomsheets to offset by the height of the system/notif-bar. newline + fitsSystemWindows = shoves my bottomsheet down I eliminated all irrelevant stuff down to buttons, textview and the bottomsheet. Button2: setText("1\n2") is where

Are Fragments and Fragment Activities inherently faster than Activities?

一曲冷凌霜 提交于 2019-12-22 05:04:38
问题 Are Fragments and Fragment Activities inherently faster than Activities? If I don't need to load my activity in fragments, should I be using FragmentActivities and Fragments over Activities? Reason I am asking is because I have been using Activities, exclusively, for years, and the Facebook SDK as well as Google Maps 2.0 have forced me to use Fragments, and I wonder now if they are inherently "better" or not, versus some other implementation. If this "not constructive" or "too open ended"

What does offsetLeftAndRight() exactly do?

孤者浪人 提交于 2019-12-22 04:08:10
问题 What does offsetLeftAndRight() exactly do? Documentation says: "Offset this view's horizontal location by the specified amount of pixels" So, does it mean that if the view's left position is suppose 50 and offsetLeftAndRight(20) is called on it, then the view will move by 20pixels & its left position will be (50-20) i.e. 30? Thanks in advance. 回答1: Both the left and the right positions will be incremented by the offset. So in your example, the left position will change to 50 + 20 = 70. 来源:

Controls behind statusbar with ViewPager & fitsSystemWindow

烈酒焚心 提交于 2019-12-22 01:29:37
问题 I have a ViewPager with Fragments which contain fullscreen images and some bottom aligned controls. I want to make sure the controls do not disappear behind the translucent navigation bar with fitsSystemWindow but I can't seem to make it work... It does work when I use the same xml without the ViewPager so it seems the ViewPager "breaks" the ability to use fitsSystemWindow . Code I have for the activity: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android

Make x-axis in vertical center using AChartEngine

情到浓时终转凉″ 提交于 2019-12-21 22:30:22
问题 I am am going to make a app where i want to create a xy graph. AchartEngine API looks very attractive to me. I have seen all their examples and demos, Searched their forum but cant figure it out that if it can able to match my requirements. So here is my question: I want a xy graph where: Make the graph non scrollable. (Pending) Make the x-axis vertically center as shown in image. (Pending) Show labels only on x-axis. (Pending) The Second Question is most important to me. Can some holly sole

How to make a customized compass view in android

本小妞迷上赌 提交于 2019-12-21 17:37:34
问题 I am working with a simple compass application. I need to set the compass view with the sensor activity for that i choose a compass view class. But it is only drawing a circle and a line for the compass view. I need to customize this view by replacing this circle and line with my own drawable images somebody please help me to fix this. My view class import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view