android-layoutparams

How to set background of collapsing toolbar with custom behavior to fit whole screen

孤者浪人 提交于 2020-01-22 20:09:27
问题 I'm following nice repo which shows how to make custom behavior of collapsing toolbar WhatsApp-ProfileCollapsingToolbar. What I don't like is when picture below toolbar (toolbar's font is white) is white then toolbar is not visible. So I'm trying to set background of toolbar to some color. First I added to widget_header_view.xml android:background="@android:color/holo_red_light" and now I have it like: <?xml version="1.0" encoding="utf-8"?> <com.anton46.whatsapp_profile.HeaderView xmlns

How to add and remove layout behavior programmatically to LinearLayout

删除回忆录丶 提交于 2020-01-06 16:01:35
问题 You can add the app:layout_behavior="@string/appbar_scrolling_view_behavior" behavior to a LinearLayout in the XML declaration but I haven't found a way to do the same in code. With a CoordinatorLayout you can call CoordinatorLayout.LayoutParams.setBehavior() but this method isn't available on LinearLayout.LayoutParams . Is there a way to do something similar for LinearLayout ? 回答1: You're misunderstanding LayoutParams concept a bit. LayoutParams object is related to the enclosing ViewGroup ,

How to add and remove layout behavior programmatically to LinearLayout

吃可爱长大的小学妹 提交于 2020-01-06 16:01:22
问题 You can add the app:layout_behavior="@string/appbar_scrolling_view_behavior" behavior to a LinearLayout in the XML declaration but I haven't found a way to do the same in code. With a CoordinatorLayout you can call CoordinatorLayout.LayoutParams.setBehavior() but this method isn't available on LinearLayout.LayoutParams . Is there a way to do something similar for LinearLayout ? 回答1: You're misunderstanding LayoutParams concept a bit. LayoutParams object is related to the enclosing ViewGroup ,

How to change width and height of existing layout params

天大地大妈咪最大 提交于 2019-12-24 16:11:04
问题 Please consider ImageView inside RelativeLayout it has some specific layout params for RelativeLayout . I need to change the width and height of my ImageView programatically according to the screen size. How can I save all layout parameters but only change width and height Following code creates empty layout params but I need to save my old params and change only height and width. imageViewArticleImage.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

WindowManager.addView ontop(overlay) of soft key OR nav bar

家住魔仙堡 提交于 2019-12-23 05:29:24
问题 I saw an app that overlays whole screen including nav bar (or soft-key that has back, home, etc.) today. it's CF.Lumen(requires android 4.4+) by chainfire. I just remembered this is NOT POSSIBLE on general approach and many SO answers told me. So I looked down smali codes from Lumens apk(sorry chainfire), found 0x7d6 as type specifier, which is TYPE_SYSTEM_OVERLAY . In general, this makes a view overlays on top of lock screen. It looks good however it won't overlays nav bar area. even on lock

Cannot resize linear layout children in android react native module

大城市里の小女人 提交于 2019-12-21 03:44:04
问题 Full code here Video of correct behavior in java and incorrect in react native here I have modified a linear layout to respond to touch by resizing the left child while the right child takes up the rest of the space, simulating a horizontal scroll that can be 'opened' or 'closed' using the following code LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) leftView.getLayoutParams(); //Log.d("ll","width " + newWidth); lp.width=newWidth; leftView.setLayoutParams(lp); In react native,

Android: permission denied for window type 2038 using TYPE_APPLICATION_OVERLAY

南楼画角 提交于 2019-12-17 19:36:30
问题 I trying to create a view that is above other applications: WindowManager.LayoutParams paramsDirectorView = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); I have looked in other responses and found the following things for "drawing over applications": I have android.permission.SYSTEM_ALERT_WINDOW in the

Setting margin programmatically to CardView

和自甴很熟 提交于 2019-12-12 10:30:39
问题 I have a CardView in my XML layout and I need to set margins to it programmatically (This is because I don't need margin at all times. Based on few conditions, I either set or remove the margin). Here's how I did it: CardView.LayoutParams layoutParams = (CardView.LayoutParams) myCardView.getLayoutParams(); layoutParams.setMargins(0, 0, SystemHelper.dpToPx(2), 0); myCardView.setLayoutParams(layoutParams); This worked fine. It put 2dp margin at the bottom of my CardView . However, I get this in

Android Windows: When and how are they created?

大城市里の小女人 提交于 2019-12-04 12:20:02
问题 I have read the standard Windows-related documentation and pawed through a bunch of the source code in an attempt to understand how and when Android Windows are created. I believe I have my arms around it and would like to have it verified or corrected. To my knowledge, there are only two ways to get a handle to a Window object. 1. Activity's getWindow. 2. Dialog's getWindow method. In both of the above cases, you can get a handle to the Window using getWindow and then manipulate the Window

How to set background of collapsing toolbar with custom behavior to fit whole screen

╄→尐↘猪︶ㄣ 提交于 2019-12-04 05:27:40
I'm following nice repo which shows how to make custom behavior of collapsing toolbar WhatsApp-ProfileCollapsingToolbar . What I don't like is when picture below toolbar (toolbar's font is white) is white then toolbar is not visible. So I'm trying to set background of toolbar to some color. First I added to widget_header_view.xml android:background="@android:color/holo_red_light" and now I have it like: <?xml version="1.0" encoding="utf-8"?> <com.anton46.whatsapp_profile.HeaderView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout