Menu
  • HOME
  • TAGS

Get screenshot of current foreground app on Android having root priviliges

android,android-activity,android-service,android-view,android-screen-support

The method that I'm going to describe below will let you to programmatically take screen shots of whatever app it's in the foreground from a background process. I am assuming that you have a rooted device. I this case you can use the uiautomator framework to get the job done....

How to create an android table dynamically by reusing one layout?

android,android-layout,android-view,indexoutofboundsexception,android-tablelayout

Use this, //Initiates the table public void init(){ //This part defines the layout to be used for creating new rows TableLayout ll = (TableLayout) findViewById(R.id.table_layout); TableRow row= new TableRow(this); TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT); row.setLayoutParams(lp); TextView tdate = new TextView(this); TextView tweight = new TextView(this); //This generates the caption row...

CircledImageView always have rectangle image in front of the circle

android,android-view,android-wear

you can create your own custom circular ImageView extending ImageView Class... i have created one.. may be you can use it.. public class CircularImageView extends ImageView { private int borderWidth; private int canvasSize; private Bitmap image; private Paint paint; private Paint paintBorder; public CircularImageView(final Context context) { this(context, null); }...

At what point in the View lifecycle should I unsubscribe if the View is never made visible?

android,android-view,rx-java,rx-android

A graphical element like a view should not be performing any logic that doesn't directly effect drawing. It should not be localizing text, instead localized text should be passed in to it.

Update ListView footer

android,android-listview,android-view,android-view-invalidate

The behavior is expected only. Calling invalidate() of any view will just re-draw the content what is there already, it will not update unless the change is in the canvas. When you change the language, the footerView is not notified, so that it can change the content. So when you...

android layout 50% above and below boundary

android,android-layout,android-view

Its little bit complicated one But it will give you the desired result Hope it will help to solve the question Xml Code : <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:text="View A"...

How to manipulate view inside ListView items?

android,listview,android-listview,android-view

Add a field in your FriendRequest class that saves the current state of the progress bar. based on it set the visibility of the progress bar. The same view row has been sent to another row. in your getView method you must always set the progress bar visibility based on...

When are views attached and detached?

android,android-view

From the official documentation: An activity is a single, focused thing that the user can do. Almost all activities interact with the user... The first thing that needs to be noted is that it is not a must for activities to be associated with a layout. You can have an...

Getting position of View in onCreateViewHolder

java,android,android-view,recyclerview,android-viewholder

You cannot use the position parameter of onBindViewHolder in a callback. If a new item is added above, RecyclerView will not rebind your item so the position is obsolete. Instead, RecyclerView provides a getAdapterPosition method on the ViewHolder. @Override public ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) { final View view...

drawing sloped rectangle upper edge shape as in yahoo digest news app using xml android

android,android-layout,android-view,android-shape

well I think it's a silly thing to answer to my question but am doing so because it may help other people. I couldn't manage to create what I need using XML. so here is how to create a sloped rectangular using onDraw method. First you need to create a...

error when using universalimageloader

android,android-view,android-library

Always a good idea to have a look at the source code for your open source library :). Code is here (I am assuming you're using the latest version): https://github.com/nostra13/Android-Universal-Image-Loader/blob/master/library/src/com/nostra13/universalimageloader/core/ImageLoaderConfiguration.java The line in question: 195 public Builder(Context context) { 196 this.context = context.getApplicationContext(); 197 } This means the context is...

linearLayout.addView(index, view) gives IllegalStateException

android,android-layout,android-view

You are receiving this error because framelayout already has a parent. Try something like FrameLayout framelayout = new FrameLayout(context); I cant provide you the exact code as I am unable to understand your code but the problem you are facing is definitely because of the reason stated above. The framelayout...

Design a button in Android

android,eclipse,android-layout,button,android-view

This is how I would create the logout button logout_button.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFD"/> <corners android:radius="15dp"/> <stroke android:width="1dp" android:color="#5C88A1"/> </shape> And the button in layout <Button android:id="@+id/btnLogout" android:layout_width="150dp" android:layout_height="30dp" android:background="@drawable/logout_button"...

Draw on the custom image view in android

android,canvas,android-imageview,android-view,android-drawable

Calculate the displayed image size first and then clamp the eventX and eventY to the bound of the displayed image. Code as below: int imageViewH=imageView.getMeasuredHeight();//height of imageView int imageViewW =imageView.getMeasuredWidth();//width of imageView int drawableH =imageView.getDrawable().getIntrinsicHeight();//original height of underlying image int drawableW=imageView.getDrawable().getIntrinsicWidth();//original width of underlying image int displayH, displayW; // the...

How to implement customized stack view in android?

android,android-layout,customization,android-view,stackview

Feel free to use my library available here. It does exactly what you want and is based on the ViewPager so you can use it with just a typical PagerAdapter of your choice....

Creating a drawable & zoomable image view in android

android,android-canvas,android-imageview,android-view,android-drawable

Answer updated with zoom enable/disable and drawableview activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <Button android:id="@+id/enable_zoom" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="disable zoom"/> <com.rbt.zoomdraw.CustomImageView android:id="@+id/zoom_iv"...

Android - custom view in action bar not clickable

android,android-actionbar,android-view

Replace View v=getLayoutInflater().inflate(R.layout.alias,null); with View v = actionbar.getCustomView(); Try this. This should work....

Android: can you have a ripple effect whose default state color is transparent?

android,android-layout,android-view,android-selector

It is not possible I have been trying this myself,... and after a little investigation I think it has something to do with the palette... the ripple seems to be using it or something similar and if you set the color to transparent, it cannot create a compatible color palette

How to add drop shadow to textview with rounded corners?

java,android,xml,textview,android-view

Try the following links, Android view shadow Designing EditText with rounded corners & inner shadow This links surely helps you :)...

GridView, Get Item's parent View

android,android-layout,android-view,android-adapter,android-gridview

Aaahh.. Something we need to try, Implement method like, private View getViewByPosition(GridView gridView, int position) { int firstPosition = gridView.getFirstVisiblePosition(); int lastPosition = gridView.getLastVisiblePosition(); if ((position < firstPosition) || (position > lastPosition)) return null; return gridView.getChildAt(position - firstPosition); } Now, call this method, if (position != -1) { // I...

How/where can I “stash”/keep data in my application?

java,android,android-layout,android-view

In your case, you should use SharedPreferences to store the data by converting it into a String (text) or int/long first. This will allow you to easily write and retrieve data, and you should use this. You can also use the file system to save almost any Java object using...

Creating a dynamic/complex Android viewText + editText layout

android,android-layout,android-edittext,android-view,android-textview

I had a similar situation where I wanted to have a list of names that would go side-to-side if possible, but if a name was long to begin on the next line. I played around with a library called android-flowlayout. It has good examples and is fairly easy to customize....

How to make a view from pieces aligned to each other with different behavior android

android,android-layout,animation,view,android-view

Exactly as you wrote, make separated view for each element with specific listener. Extending View should be sufficient solution - it gives you needed interfaces (e.g. OnDragListener or OnClickListener) and let you to keep clear your solution. This seems to me like really pleasant task, which you can solve step...

Change color on state change for custom view

android,android-layout,android-canvas,android-view,android-styles

Well, the easiest way to do it would be to change Paint object's color in on touch method of your custom view. You could do it more less like this: @Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()){ case MotionEvent.ACTION_DOWN: paint.setColor(mPressedColor); invalidate(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: paint.setColor(mNormalColor); invalidate(); break;...

Getting Class is not a View Error When Using a Custom Class in Layout - Android TV

android,android-layout,android-view,android-tv

If by "the Row class" you mean this Row class, that is not a widget, despite being in a Java package with widget in the name. Row inherits from Object, not View, and so you cannot use it in layout.

How to change to parameter in custom view at run time?

android,android-view,android-lifecycle,android-overlay

Add a member variable and setter function to the DrawView class: private int mLineColor = Color.RED; public void setLineColor(int color) { mLineColor = color; drawPaint.setColor(mLineColor); } Change your onDraw to use it: drawPaint.setColor(mLineColor); Then you can set it from the Activity that uses your custom class, inside the Button onClick()...

How to determine which View was clicked in a ListView with custom layout

android,android-view

Basically, what you have to do is, make that imageview to capture onClick events by set its xml value : android:clickable="true" After you set that in your custom layout for the imageView called "mVideoFavorite", you must implement its onClick method as follow inside your getView method for custom adapter: @Override...

Android - how to detect gesture on a specific View?

android,android-view,gesture

http://developer.android.com/training/gestures/index.html yourView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ...your code } }); ...

View added to Layout inherits parent's style

android,android-layout,android-view,android-styles

You need to provide the dialog's context instead of the activity context to the button so that it can retrieve the correct theme (the Dialog base class uses a ContextThemeWrapper to wrap the activity context while providing it's own theme). Replacing the getActivity() that was passed to the button constructor...

Android, UI Element in custom View

android,android-view,ondraw

It is very very possible to incorporate native elements, I do it daily, but you're doing it very wrongly. You don't directly draw them, you only directly draw if you're really doing a custom drawing, if you want an existing view inside your CustomView, you add that view to your...

fragment doesnt show the layout

android,android-layout,android-fragments,android-view

change @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { inflater.inflate(R.layout.contacts_picker_activity, null); return super.onCreateView(inflater, container, savedInstanceState); } to @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { return inflater.inflate(R.layout.contacts_picker_activity, container , false); } you need return your view that want to inflate in onCreateView...

Android - Screen not updating when removing view

android,android-layout,android-view

This is so not the way to populate a data screen. I don't mean to sound impolite but your fundamental approach is wrong here. You're basically doing everything -- from interacting with your data model to manipulating the view hierarchy directly -- from within your Activity itself. That's not the...

how to completely hide a row from tableLayout android?

java,android,android-layout,android-view,android-tablelayout

Use View.GONE instead of View.INVISIBLE View.INVISIBLE only makes the View invisible. It is still added to the View hierarchy, and space is allocated for it. Whereas View.GONE removes the View from the ViewGroup as though it was never present in the first place. What's more, you can get it back...

Android onTouch recognized on other view

android,android-view

So I managed to fix this strange behaviour by putting buttons with the same parent into separate parents, that is adding them linear (or other) layouts like this: UPDATED XML: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/activity_game_circle1" android:layout_width="120dp" android:layout_height="120dp" android:text="1" android:gravity="center" android:textSize="36sp"...

Data binding: presentation model and view, 3rd party libs in Android

android,model-view-controller,android-view,android-viewbinder,presentation-model

Android M will provide powerful library for data binding! It's available now in dev-preview version. It looks amazing inside xml and java files: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{user.firstName}" /> Java bean: public class User { private final String firstName; private final String lastName; public User(String firstName, String lastName) { this.firstName =...

Android: Can we even “design” our own widgets and layouts?

android,android-layout,widget,android-view,android-viewgroup

this means people can even design their own widgets and layouts? Yes. Does that ever happen? Yes. Any examples? There are hundreds of examples out on the Android Arsenal alone. Just looking at a couple of columns of the recent items, there are the following custom widgets and containers:...

How to add elements directly to FrameLayout at android:id/content?

android,android-layout,android-view,glsurfaceview

It's an activity's root view and can be fetched like this: FrameLayout frame = (FrameLayout) findViewById(android.R.id.content); ...

Android Custom View: getting null references on every class members in the onDraw method

java,android,nullpointerexception,android-view,ondraw

your init method is empty. Your code works only if you instantiate programmatically your custom view. If you declare in an xml, the Bitmap and the String are not initialized. Use init to initialized, and call it also in the constructor that takes only the Context as parameter private void...

How to drag and drop while preserving the original android View?

android,android-layout,drag-and-drop,android-view

Issue was that I was setting the view invisible (facepalm) in response to the touch listener. Furthermore my shadow was passing the view to super() making the view come along for the ride. Combined effect was the appearance of the view being dragged away and lost forever. Fixed by removing...

Android: Adding fragments with android.R.id.content

android,android-layout,android-fragments,android-view

I add the same problem when trying to add a PreferenceFragment to an ActionBarActivity : the fragment does not show at all (it works on a simple Activity). I solved it by defining a dummy layout xml file, with a single frame layout. Then I replace this layout with my...

How to use the MultiTouchController library? (Android)

android,android-view,multi-touch

Change line 160 (https://code.google.com/p/android-multitouch-controller/source/browse/MTPhotoSortr/src/org/metalev/multitouch/photosortr/PhotoSortrView.java#160) to if (im.containsPoint(x, y) && i!=theImageInTheCenter) and, define the variable int theImageInTheCenter = 3; if its for example the 3rd image (R.drawable.tahiti) that shoulnt move...

TextView and EditText cut off in LinearLayout

android,android-layout,android-edittext,android-view,android-textview

Your LinearLayout has an orientation of "horizontal" - it will add the next view to the right of the current view. This means that if the TextView wraps (fills the parent) there is no room for any additional views in the LinearLayout that will be visible on the screen (they...

Changing the visibility of views one at a time with a button

java,android,android-view,android-button,android-looper

int i = 0; onClick(View v){ switch(++i){ case 1: view1.setVisibility(View.GONE); break; case 2: view2 setVisibility(View.GONE); break; case 3: view3.setVisibility(View.GONE); i = 0; break; } } ...

how do i check if the edit text view contains 2 white spaces?

android,android-fragments,android-edittext,android-view,android-textview

You can use a regular expression to do that. Use code like this one: if(Pattern.matches("^\\w+\\s\\w+\\s\\w+$", mSearchView.getText().toString())) Also make sure to check if mSearchView.getText() is not null - you probably will get a NullReferenceException with a blank EditText content. In the end you may want to create a method like this...

View.OnClickListener in a custom DialogFragment

android,android-view,onclicklistener,android-dialogfragment

I am just showing you the important part.. i hope you find their respective lines in your code final View view = inflater.inflate(R.layout.dialog_settings, null); // inflating your view..for drawback, this line is [A] your colorButton has a reference to view.findViewById(R.id.colorButton_dialogSettings) which is from the viewgroup view..which you reference an onclick...

layout_gravity center along with layout_marginRight issue

android,android-layout,android-view

When you're doing android:layout_gravity="top|center" I think that margin_right is making go the view to the left Could that be it? Edited I used your code to see and this is the result ...

how to prevent a View from being “pressed” on touch event

android,android-view

In the onTouch() method, return false. This will tell Android that the OnTouchListener is not responsible for handling the gesture.

Scaling bitmap image in custom view listview item

android,android-layout,android-view

Try using Picasso for downloading/caching, it can better the quality / download speed: http://square.github.io/picasso/...

How do I use the default android Button drawable as the background of another view?

android,android-layout,android-view,android-button,android-background

Have you tried to use Button's style like this. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/buttonStyle" android:id="@+id/linlay_add_category_area_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="horizontal" android:padding="13dp"> ... </LinearLayout> ...

Styling an Android edit text so as to look like a drop down / spinner picker

android,android-layout,monodroid,android-view

set the Style attribute to the following: <EditText style="?android:attr/spinnerStyle" android:layout_width="match_parent" android:layout_height="wrap_content" /> ...

How do I update my TextView in MainActivity after exiting a dialog fragment?

android,android-layout,android-fragments,android-view,android-timepicker

You want to create an Interface in the Dialog Fragment. When the time is picked it will notify the Activity. Let me know if this gives you any issues. Fragment public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current time as...

update Views in layout when a view changes

android,android-layout,android-linearlayout,android-view

ViewProperties like translationX/Y/, rotationX/Y does not affect the layout of the view hierarchy. If you want both view to be translated, you have to translate the second view as well. Or you could add some margin on top of the first view, this will push both view downward....

Android : How can I keep all drawings?

android,android-canvas,android-view,android-drawable

You should keep track of the lines within a Path component. Add to the path when you have a new line to draw. Then you can draw the path within the onDraw() or clear the path when you need to for whatever reason. Path | Android Developers One example might...

How to find a View in a BridgeContext?

android,android-view

I awarded the bounty to dandc87 because his answer led me to the solution. However, the code snippet in his answer crashes with a ClassCastException because the root ViewParent is not a View. The mods keep rejecting my edits, so here's the complete and correct solution: private View findPeerById(int resId)...

What are the limitation in EditMode for custom views in Android?

android,android-view,android-custom-view,editmode

Custom views should work just fine as long as they only call parts of the view framework, not any application code. That's a good separation to have for views anyway: they should contain view state, not app logic. Typically you only have to use View#isInEditMode if your custom view is...

FrameLayout IllegalStateException: The specified child already has a parent

java,android,android-layout,android-view

A view can only have one parent. onCreateDialogView will return dialogView, which will then be added to a view (and thus receive a parent). If onCreateDialogView is called a second time, dialogView will already have a parent and will throw an IllegalStateException. Instead, initialize dialogView and picker inside of onCreateDialogView...

Custom View: Canvas draw methods give API error

android,android-studio,android-canvas,android-view

The drawOval() method that you are using from canvas was added in API 21. public void drawOval (float left, float top, float right, float bottom, Paint paint) - API 21. You should try using the drawOval() with RectF parameter, instead. public void drawOval (RectF oval, Paint paint) - API 1...

Android left and right alignment of listview

java,android,android-layout,android-view,android-xml

You have to override getItemViewType(int position) and getViewTypeCount() Lets say you have two types of layout (left and right) then @Override public int getViewTypeCount() { return 2; } and @Override public int getItemViewType(int position) { return listItems.get(position).getme(); // hoping this returns value as 0 and 1 } In your getView...

How to approach custom Layout

android,android-layout,android-view

You can't find a good tutorial about UI , so i tried to do it for you using just xml ! i was just editing padding and layout_weight ..and layout_gravity .. these are the important things you need The Phone Screen (4") The Tablet Screen (10.1") here is the layout...

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

android,android-studio,android-view,android-custom-view

I just changed xmlns:app="http://schemas.android.com/apk/res-auto" to xmlns:app="http://schemas.android.com/apk/lib/com.app.chasebank" and it stopped generating the errors , com.app.chasebank is the name of the package. It should work according to this Stack Overflow : No resource identifier found for attribute 'adSize' in package 'com.google.example' main.xml...

Android ScrollView, check if currently scrolling

java,android,android-listview,android-view,android-scrollview

ScrollView in its current form does not provide a callback for detecting scroll events. There are two workarounds available: 1. Use a ListView and implement OnScrollListener. 2. Derive a custom class from the existing ScrollView implementation and extend it to provide callbacks for scroll events....

Difference between view.findViewById(R.id…) and just findViewById(R.id…)

android,android-view,findviewbyid

findViewById aways requires a context to find the view. If you are calling this from an class which is extended from activity, you could just use findviewbyid, because activity is the context. When you are using this in a class that extends fragment, you have to use getactivity().findviewbyid In your...

I can not deal with interface callback

android,android-view

Within the date picker class, you want to implement a simple interface. public class MyDatePicer extends DialogFragment implements DatePickerDialog.OnDateSetListener { Bundle bundle; String myString // Interface MyDatePicerListener mListener; public interface MyDatePicerListener { public abstract void setDateBegin(String log); public abstract void setDateEnd(String log); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { }...

Android java make two similar for loops into one loop

java,android,for-loop,view,android-view

Try this: int maxDataSetSize = Math.max(data1.size(), Math.max(data2.size(), data3.size())) ; int maxDataSetSize2 = Math.max(data4.size(), Math.max(data5.size(), data6.size())); for (int i = 0, j = 0; i < maxDataSetSize || j < maxDataSetSize2; i++, j++) { View statsRowview = getLayoutInflater().inflate(R.layout.stats_row, null); if(i < maxDataSetSize){ String dataset1Value = data1.size() > i ? data1.get(i) :...

Android:onclick behavior

android,onclick,android-view

The parameters view in this case is the button that is clicked From: Android UI Events Within the various View classes that you'll use to compose your layout, you may notice several public callback methods that look useful for UI events. These methods are called by the Android framework when...

android:fitsSystemWindows not working

android,android-view

My problem was most likely related to multiple/nested fitsSystemWindows attributes which does not work as I found out later. I solved my problem by applying the attribute to one view, and then copy the paddings to other views that need them via an ViewTreeObserver.OnGlobalLayoutListener. That is an ugly hack, but...

InflateException: Binary XML file line #1: Error inflating class when using Ripple

android,android-view,android-selector

Ripple is not backported due of the performance of the pre-lollipop UI thread. You should create two different directories (drawable-v21 and layout-v21) that contains stuff available up lollipop

OnclickListner on a custom listview adapter

android,android-listview,android-view,onclicklistener,baseadapter

In your activity after setting adapter to listview call yourListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) { // TODO Auto-generated method stub //based on position you can get id } }); EDIT : To get clicked user details in ListView use convertView.setTag(m) in...

Android ActionBar not visible

java,android,android-layout,android-actionbar,android-view

Make sure that your activity extends the ActionBarActivity. Like this: MainActivity extends ActionBarActivity. I found that when I remove this and extend something else that the action bar would disappear. Also check the theme of the xml and change it. Check this out: can I use a compatible action bar...

Android : How can I have XML layout and the views that I added to my layout?

android,xml,android-layout,android-view

Debugging is your solution. Make sure that the view that you are adding does not overlap your textView. Make sure your textview has text. Try checking its size in run time. And finally use Android Studio layouting tool, to have a preview of your layout. You can use tools to...

What am I missing here - in implementing tabs in my activity?

android,android-layout,android-view,android-tabs,fragmentstatepageradapter

With the API 21 the method setNavigationMode(ActionBar.NAVIGATION_MODE_TABS) is deprecated. Refer this. If you prefer to have a tabs like google play store style, u can use PagerSlidingTabStrip library. Google example for SlidingTabsBasic...

What does View type mean?

android,android-view,android-adapter

Not all items in an Adapter need to have the same View to represent them. The view type is just an int that says which type it is- basically an enum defined at run time. If there's only 1 view, they should all return 0. If there's multiple views, then...

ViewPropertyAnimator without start call, is there a difference?

android,android-animation,android-view,viewpropertyanimator

public void start () Starts the currently pending property animations immediately. Calling start() is optional because all animations start automatically at the next opportunity. However, if the animations are needed to start immediately and synchronously (not at the time when the next event is processed by the hierarchy, which is...

Decapitalizing text in Android view

android,android-view,android-textview

add: android:textAllCaps="false" to the style of the button so change: <Button android:id="@+id/TestButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ExaMple" /> to: <Button android:id="@+id/TestButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAllCaps="false" android:text="ExaMple" /> ...

reset Android FrameLayout object to “clean” state

android,android-layout,android-view,framelayout,object-pooling

No, there isn't. If you weren't trying to do recycling I'd suggest just creating a new one is the easiest way to ensure it. Its also not a very efficient thing to do in general- there's a lot of pieces of state that can be changed, if you try to...

Focus is Getting Lost on adapter.notifyArrayItemRangeChanged

android,android-activity,android-view,android-tv

This should get called only for the item that needs to be focussed vh.mButton.requestFocus(); If you notify the adapter just for the first item in the ActionPresenter, onBindViewHolder will be called just for the first item and it will get the focus. If it is the second item that needs...

How to get the selected date from android TimeSquare library?

java,android,android-view,android-calendar,android-time-square

Here is my Ans: calenderView.setOnDateSelectedListener(new OnDateSelectedListener() { @Override public void onDateUnselected(Date date) { } @Override public void onDateSelected(Date date) { Toast.makeText(HomeActivity.this,calenderView.getSelectedDate().getTime()+"", Toast.LENGTH_LONG).show(); tv.setText("Pickup Date:" +calenderView.getSelectedDate().getTime()); } }); ...

Difference between an AppCompat view and a normal Android view

android,android-view,android-support-library,appcompat

When you are using Button or EditText you are actually using AppCompatButton and AppCompatEditTextFrom official doc of AppCompatEditText A tint aware EditText. This will automatically be used when you use EditText in your layouts. You should only need to manually use this class when writing custom views ...

Android switching focus makes keyboard disappear

android,android-view

Use these lines after focusing next item to open a keyboard InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.toggleSoftInputFromWindow(yourEditText.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0); ...

how to dynamically create xml layout multiple times inside getview() method in android?

android,android-view,android-xml,layout-xml

I see three approaches for you. As discussed in the comments the title of your question is misleading, so this is what I assume: you have a list of cards you want to display each card may have a list of comments So the underlying problem is, that you have...

How to select and deselect an image in android?

java,android,android-layout,android-view

Finally I've found the right answer. I think it can be helpful. So I share it. First of all, I introduced a Rigion object like this in the DragView class: public Region region; then, I added a line to my constructor as this: region = new Region(mView.getLeft(), mView.getTop(), mView.getRight(), mView.getBottom());...

How to get a list of all views in a fragment?

android,android-fragments,android-view

Ok, fragment has method getView() : Get the root view for the fragment's layout (the one returned by {@link #onCreateView}), if provided. @return The fragment's root view, or null if it has no layout. You can do this like: try { ViewGroup rootView = (ViewGroup) getView(); int childViewCount = rootView.getChildCount();...

Android scale view and re-layout

android,android-layout,android-animation,android-view

You want to add a scaleY animation on View A before displaying View B right? It is absolutely possible. I'm not sure what is the 'white-block' you're referring to. You should give some of your code if you want help debugging. Otherwise, you should use an ObjectAnimator like this one...

Android - ActionBar - PopupMenu - Error

java,android,android-studio,android-actionbar,android-view

Try to Restart emulator Or Check in Real Device Because sometime emulator not behave good, you need to test on real device if possible. ...

Can components be interacted with when their visibility is set to GONE?

android,android-view

When the visibility is set to GONE, the component is removed from the view hierarchy and no space is set aside for it. Moreover, there is no way for the user to interact with it (However, changes made to the View by the programmer while it is GONE become manifest...

Add view by sliding in from left

android,android-animation,android-view

This will solve ur problem myView.startAnimation(AnimationUtils.loadAnimation(mContext, android.R.anim.slide_out_left)); ...

Reset all Views in fragment

android,android-fragments,android-viewpager,android-view

Let's break it down into steps: 1. Getting the references How this is done depends on what you already have. If the fields are created in-code, it's easy: Just store the references in a List<CommonBaseType>. If they are loaded from an XML Layout, there are multiple options. If you just...

ImageView.Visible and ImageView.Gone is not working android

android,android-view

Use postDelayed like this. public void changeRightDrum() { System.out.println("RIGHT"); imageViewB.setVisibility(View.VISIBLE); imageViewB.postDelayed(new Runnable() { @Override public void run() { imageViewB.setVisibility(View.GONE); System.out.println("RIGHT DONE"); } }, 100); } ...

Android line path morphing animation

android,android-animation,android-canvas,android-view

I suddenly started to look into object animators. The solution is to use one that animates from my current percentage to the new percentage. The result is exactly what I wanted. Here is the updated view: public class ProgressDownload extends View { private static final String LOG_TAG = ProgressDownload.class.getSimpleName(); private...

Draw on the image instead of image view in android

android,android-canvas,android-view,android-custom-view,android-drawable

You should possibly use SurfaceView instead. It is more advanced compared to ImageView. Refer to this for drawing: http://examples.javacodegeeks.com/android/core/ui/surfaceview/android-surfaceview-example/ This is for zoom: http://android-innovation.blogspot.co.nz/2013/07/how-to-implement-pinch-and-pan-zoom-on.html...

Drawing a path in android progressively

android-canvas,android-view,objectanimator

I somehow figured it out how to achieve it. I, however could not directly draw a canvas line with animation though but found out a work around and that actually worked for me. I used a horizontal progress bar instead with a negligible height which will look like a line...

Android - How to make a visible element push other elements

android,android-layout,android-view

if these elements are just next to each other, you can use a linear layout and set the gravity to right. the linear layout automatically pushes the elements. in relative layout all elements are "relative" to another element or the parent view, but just to one element for each direction....

Position View above current layout but not above navigation bar and status bar

android,android-layout,android-view

how about this MyView myView = new MyView(context) FrameLayout root = (FrameLayout)activity.getWindow() .getDecorView();//your decorview is a FrameLayout root.addView(myView,0);//can add params Edit for the logic, first of all get the location of the navigation bar on the Screen by getting a reference to the navigation bar and calling getLocationOnScreen(int[]) after if...

What is this Android Circular View

android,user-interface,android-view

Thanks everyone who posted the comments. Let's call this custom widget Circular SeekBar https://github.com/RaghavSood/AndroidCircularSeekBar https://github.com/devadvance/circularseekbar https://github.com/TriggerTrap/SeekArc Or Circular ProgressBar https://android-arsenal.com/details/1/1513 https://android-arsenal.com/details/1/1446 https://github.com/passsy/android-HoloCircularProgressBar...

How to map variable and view in android?

android,android-layout,android-view,layout-inflater

for(String key: hm.keySet()) { View oneItem=inflater.inflate(R.layout.oneItem, linearlayout, false); TextView tv=(TextView)oneItem.findViewById(R.id.value); tv.setText(hm.get(key)); oneItem.setTag(hm.get(key)); linearlayout.addView(oneItem); } Now whenever you find that item you can find like View view=linearlayout.getTag(hm.get(key)); ...