android-view

Altering UI thread's Views in AsyncTask in doInBackground, CalledFromWrongThreadException not always thrown

北慕城南 提交于 2019-12-12 22:11:15
问题 The following code in an AsycnTask: @Override protected Boolean doInBackground(View... params) { try{ Drawable drawPhoto = DataDatero.ImageDownload(taskPhotoName); ((ImageView)params[0]).setImageDrawable(drawPhoto); ((TextView)params[1]).setText(taskItemListText); ((TextView)params[2]).setTextColor(taskColore); ((TextView)params[2]).setText(taskItemStockText); [...] } Throws a CalledFromWrongThreadException , describing that: Only the original thread that created a view hierarchy can touch

MotionEvent.obtain(…); not working as on screen tapper

送分小仙女□ 提交于 2019-12-12 21:27:41
问题 This is a continuation of my first topic here, about how to use code to mimic an on screen touch. I wanted to incorporate this function to a floating, onscreen, chat-head (like what facebook did). So basically, when I tap the chat-head this service will mimic taps a certain amounts of times and at a certain rates. (Which are predefined somewhere else.) It will also mimic the tap at a certain spot x, y. (which are also predefined.) I want the service to tap whatever is behind (on the screen).

Background with directional arrow

走远了吗. 提交于 2019-12-12 13:36:28
问题 I have a quick question on how to achieve a desired view of a background on a view. What I want is a directional arrow pointing in a direction as the overlay on a background of say a textview. For example (Beautiful MS Paint skills) I have already tried using a layer-list which isn't going to work in this case due to screen size changes or fluctuating content heights. Is there any other possible way to do this other than using a 9patch. I've been dreading to even research 9 patches due to my

Why findViewById() return null for a view in a drawer header?

☆樱花仙子☆ 提交于 2019-12-12 11:12:14
问题 I have a DrawerLayout which wraps a NavigationView with a header layout. The XML is below: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="match_parent" android:layout_height="match

Force re-layout on a viewgroup including all its children

好久不见. 提交于 2019-12-12 11:11:06
问题 I am writing up a custom layout (which extends FrameLayout ) that can be zoomed in. All its children are also custom views which would actually get the scale factor from their parent via a getter method and scale accordingly by setting the scaled dimensions like protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); float scaleFactor = ((CustomLayout) getParent()).getCurrentScale(); setMeasuredDimension((int)

Android MediaMetadataRetriever wrong video height and width

╄→尐↘猪︶ㄣ 提交于 2019-12-12 10:54:38
问题 I want to retrieve height and width of video, I am using MediaMetadataRetriever class for this. It is working correct for most of the case, but for few case height and width are interchanged. I think this might be happening because of orientation change. My current code: MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); metaRetriever.setDataSource(videoPath); videoHeight = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); videoWidth =

'Share via' application that runs without a View

丶灬走出姿态 提交于 2019-12-12 10:24:04
问题 I want to write an app that sits in the 'Share via' menu (for quickly emailing myself links to things I find on the web or look at in RSS readers) For this I'm declaring my app with an intent.action.SEND intent-filter: <activity android:name="uk.co.baroquedub.checkit.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent

Add labels above Seekbars steps with different font size, vertically aligned to seekbars thumb

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:12:41
问题 I would like to create a Seekbar , above which there will be text label on each Seekbar step, what it should look like is shown in below image this is the expected result, for which what i have done, <RelativeLayout android:id="@+id/layout_font_size" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/txtFont_size_hint" style="@style/textStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/Aa" />

How to half overlap images in android constraint layout

China☆狼群 提交于 2019-12-12 08:36:31
问题 Is there any way to place an images half is on top of another image using only constraint layout. I know it can be done using relative and frame layouts but in the case of constraint layout is there anyway? prefer ways which do not require any hardcoding of heights/widths the requirement will look like this 回答1: you can set layout using only constraint layout like below : <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android

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