android-view

Strange behavior of inflated buttons when changing one's color

↘锁芯ラ 提交于 2019-12-19 10:19:08
问题 I am trying to implement a dynamic button inflation for my Android application, based on an input specified by the user in real time. When clicked, button changes its color from blue to red. The code responsible for this goes as follows: LayoutInflater layoutsInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout linearLayout = (LinearLayout) findViewById(R.id.layout_for_buttons); // Let's say that now we need only 3 buttons: for (int i = 0; i < 3; i++) {

Translucent status bar in Android

偶尔善良 提交于 2019-12-19 06:18:50
问题 I am using the following layout (main_activity.xml) <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android

Loading images in GridView using Universal Image Loader

亡梦爱人 提交于 2019-12-19 05:46:43
问题 I'm using the Universal Image Loader 1.8.6 library for loading dinamically images taken from web. The ImageLoaderConfiguration configuration is the following: ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) .memoryCacheExtraOptions(480, 800) // default = device screen dimensions .threadPoolSize(3) // default .threadPriority(Thread.NORM_PRIORITY - 1) // default .denyCacheImageMultipleSizesInMemory() .memoryCacheSize(2 * 1024 * 1024)

How to reset ObjectAnimator to it's initial status?

本秂侑毒 提交于 2019-12-19 05:32:22
问题 I want to vibrate a view with scaleX and scaleY, and I am doing it with this code, but the problem is that sometimes the view is not correctly reset, and it shows with the scale applied... I want that when the animation ends, the view must be seen with its original status always this is the code: ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.9f); scaleX.setDuration(50); scaleX.setRepeatCount(5); scaleX.setRepeatMode(Animation.REVERSE); ObjectAnimator scaleY =

Rotate and scale a view based on one handle in Android

大兔子大兔子 提交于 2019-12-19 04:14:22
问题 I'm trying to rotate and scale a view based on one "drag" handle in Android. With the layout rotating, and the view resizing, the end result should be that the drag handle follows the users finger where ever it moves. This is based on combining these two questions: How to scale a view in android using a handle? Rotating around two points in android not working The only thing that seems wrong is the rotation code. Here is my activity code: public class MainActivity extends Activity { ImageView

View too large to fit into drawing cache when calling getDrawingCache()

北城余情 提交于 2019-12-18 17:13:15
问题 I'm trying to take a screenshot of the contents of a LinearLayout. The layout contains a scrollview that can be of variable height/width. This code works fine when the layout is not too big (i.e. you don't need to scroll very much off screen to see everything): View v1 = (LinearLayout)theLayout; v1.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); However, if the LinearLayout that I'm trying to capture is large, then the

What is the correct way to implement a GridViewPager on Android Wear?

醉酒当歌 提交于 2019-12-18 16:39:50
问题 I'm trying to implement a GridViewPager so I can switch between 2 unique views. So far I haven't been able to add any views at all. Below is my code public class Gridder extends Activity { private TextView mTextView; GridViewPager gridViewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gridder); final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); final LayoutInflater inflater

Overriding View.onSaveInstanceState() and View.onRestoreInstanceState() using View.BaseSavedState?

て烟熏妆下的殇ゞ 提交于 2019-12-18 14:43:13
问题 Assume you want to derive your own View class from an existing View implementation, adding a bit of value, hence maintaining a few variables which represent your View's state in a meaningful way. It would be nice if your View would save its state automatically just like others do (if an ID is assigned) so you would want to override onRestoreInstanceState() and onSaveInstanceState() . Of course, you need to call the respective methods of your base class, and you need to combine your state

Change the behaviour of a GridView to make it scroll horizontally rather than vertically

谁说我不能喝 提交于 2019-12-18 13:32:20
问题 I want to make a UI element like a GridView , I want it's complete functionality but want it to be horizontally scrollable rather than vertically. By horizontal scroll I mean it should be built that way and not put in a HorizontalScrollView . My would be Custom GridView will have fixed number of rows say 4-5 and the columns should be extensible based on number of items in the Adapter . You can think of it as the opposite of what the native GridView does, yet it should maintain the

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

两盒软妹~` 提交于 2019-12-18 12:47:53
问题 Something like the following, but it doesn't work. If I switch the drawable color to something like blue, it works. <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item android:drawable="@android:color/transparent"/> </ripple> 回答1: It's necessary to add a mask: <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight"> <item android:id="@android:id/mask"> <color android