android-view

Updating Views from non-UI threads

一笑奈何 提交于 2019-12-30 04:59:07
问题 I am confused about how the Android system works, specially when it updates the view hierarchy. We all know that we should not update any view from any thread other than UI (Main) thread . And even Android system throws exception when we try to do so. The other day I was trying to implement a custom progress showing view in my application. So I started with using standard Java threads and handler combo. What I found surprised me as I was able to update a TextView from background thread. new

ViewPager + SurfaceView = long delay when navigating back to activity

喜夏-厌秋 提交于 2019-12-30 01:29:29
问题 Basically what the title says, My application consists primarily of a ViewPager which uses a FragmentStatePagerAdapter The problem occurs when I add a series of SurfaceViews to the FragmentStatePagerAdapter. Just for testing purposes I did not subclass the SurfaceViews in any way. When I navigate a few pages in, hit "home," and then return to the activity, the entire device freezes for a second or two before rendering anything. I can launch and finish() the app several times in the time it

How to properly remove padding (or margin?) around buttons in Android?

耗尽温柔 提交于 2019-12-29 03:14:27
问题 Currently, I have the following bottom log in button. When button is not being pressed When button is being pressed The XML looks like this <LinearLayout android:background="?attr/welcomeBottomNavBarBackground" android:orientation="horizontal" android:id="@+id/sign_in_bottom_nav_bar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <Button style="?android:attr/buttonBarButtonStyle" android:id="@+id/sign_in_button" android:layout

Receiving hidden status bar/entering a full screen activity event on a Service

两盒软妹~` 提交于 2019-12-29 00:40:51
问题 I have a service that adds some views to the window manager (something like facebook's chat heads). This views stay on top of everything all the time, even when I'm on the camera app. Is it possible to know when some activity (like the camera or a video player) is using full screen so I can hide my views? Edit: There's something called View.OnSystemUiVisibilityChangeListener but it requires API 11. My target is 9, but it looks like this is exactly what I need. Any alternative for API 9? 回答1:

Receiving hidden status bar/entering a full screen activity event on a Service

限于喜欢 提交于 2019-12-29 00:40:36
问题 I have a service that adds some views to the window manager (something like facebook's chat heads). This views stay on top of everything all the time, even when I'm on the camera app. Is it possible to know when some activity (like the camera or a video player) is using full screen so I can hide my views? Edit: There's something called View.OnSystemUiVisibilityChangeListener but it requires API 11. My target is 9, but it looks like this is exactly what I need. Any alternative for API 9? 回答1:

No resource identifier found for attribute ' ' in package 'com.app…'

不想你离开。 提交于 2019-12-28 01:46:06
问题 I've imported a project from eclipse to Android studio. It utilizes a custom view: xmlns:app="http://schemas.android.com/apk/res-auto" I get errors in the lines below from activity_ro.xml file like: "Error:(136) No resource identifier found for attribute 'pstsTabPaddingLeftRight' in package 'com.app.xxxx'" app:pstsDividerColor="#00000000" app:pstsIndicatorColor="#FF33B5E6" app:pstsTabPaddingLeftRight="14dip" app:pstsUnderlineColor="#FF33B5E6" /> I'm not sure if custom views are different for

How get Button coordinate?

泪湿孤枕 提交于 2019-12-25 07:17:11
问题 I have a layout activity_main.xml : <Button android:id="@+id/button" android:layout_marginTop="50dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|top" android:text="@string/hover"/> </FrameLayout> How can i get Button's coordinate (x, y) on screen. for now I use: button.getX() button.getY() but it return 0.0 , How can i achieve this. Thanks 回答1: This happens because you are getting the coordinates of your view before it's

Pass image from activity to custom view edit

不羁岁月 提交于 2019-12-25 06:23:41
问题 I had create an Activity class and CustomView class. The Activity class able retrieve image from local storage(gallery) and show as ImageView. The CustomView class is build with basic drawing feature such as doodle, erase, save. The question is: After I get the image from gallery, I need to pass the image from Activity class to CustomView class for edit. How should I do that ? Here is my CustomView class (I had remove the unnecessary code, only show the method name): class DrawView extends

How can I create a custom View with a Relative Size?

…衆ロ難τιáo~ 提交于 2019-12-25 06:19:07
问题 I would like to design an application which could work with devices of any screen resolution. My idea to do so was to create one Custom View for each type of View I use, and use the layout_width and layout_height specified in the XML as a percentage of the parent size (for example, layout_width="100dp" is equivalent to fill_parent , and layout_width="50dp" means the View 's width will be half the parent's one). Here is the custom TextView class I made: public class RSTextView extends TextView

GridView, Get Item's parent View

て烟熏妆下的殇ゞ 提交于 2019-12-25 03:15:14
问题 I'm trying to send clicks to my child elements in GridView with a single touch event. So far, I can retrieve the data of the child element, but cannot perform a click on it. Let me explain a bit more on the layout of things... GridView - Touch Event Handler here... LinearLayout - onClick listeners here... TextView - Just some text... An adapter fills GridView with LinearLayout 's who have onClick events defined. These layouts contain TextView s where TextView.setText("Some data from my