layoutparams

Issue Filling Parent View When Inflating Linear Layout

自作多情 提交于 2019-12-13 05:31:33
问题 The LinearLayoutOutlined class I'm using is from this answer with only a few small edits for color. This is what my current activity looks like. There is a horizontal scroll view in the center that I want to fill with items by putting them in the layout_holder . This is the xml layout for the page: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:configChanges="keyboardHidden|orientation|screenSize" android:layout

set layout margins dynamically

不羁岁月 提交于 2019-12-13 03:21:21
问题 I have a vertical layout that contains 10 relative layouts. The UX team has prepared a background with horizontal lines so I have to fit the 10 relative layout elements dynamically on the screen. I have wrote the following code to set a listener to get the vertical layout height and then to do the calculations. The problem is I get height value of -2. final LinearLayout layout = (LinearLayout) findViewById(R.id.fav_layout); final Context context = this; ViewTreeObserver vto = layout

setLayoutParams doesn't work second time

纵饮孤独 提交于 2019-12-12 13:16:39
问题 I have written the following code to first increase the size of ImageView and after 100ms decrease the size of the same ImageView. However this code increases the size of ImageView but it doesn't decrease it's size or the code after 100ms delay doesn't affect the imageView dimensions. What am I doing wrong? uiHandler.post(new Runnable() { @Override public void run() { FrameLayout.LayoutParams layout = (android.widget.FrameLayout.LayoutParams) imageView.getLayoutParams(); layout.height = (int)

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

“specified child already has a parent” error

假如想象 提交于 2019-12-12 01:52:41
问题 I have a page that will display a weeks worth of scheduled games for a selected sport. The selected sport and week is stored within a XML file that is opened at the the start of the page. When I click on the next week link, a new week date value is stored to this xml file and then the page is reloaded.Any games for this next week should now be displayed. These games are displayed in a tablelayout where I programmatically create the rows as needed in the .java page. Here is a simplified sample

Modifying button height dynamically in upward direction

瘦欲@ 提交于 2019-12-12 00:50:31
问题 I'm trying to create graph-like structure using buttons. I want to modify the height of these buttons dynamically based on the value of seek bar. I'm able to implement this as shown in this screen shot 1. But the problem is buttons grows in height in downward direction (which is their default behavior). How do I make buttons grow upward as shown below? Xml <Button android:id="@+id/btnGraph" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id

startActvtiy in Doze mode on Android Pie

拈花ヽ惹草 提交于 2019-12-11 15:56:16
问题 I am developing a VoIP calling App. everything is fine on prior to Android Pie. On When device is in Doze (Deep Sleep) mode it received FCM and starts rising but it does not show the call Activity. How can I Show Activity on Lock Screen in Doze mode on Pie ?? I am using following Flags in my call Activity. getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager

Android get location of dynamicly added views

邮差的信 提交于 2019-12-11 09:43:39
问题 In my application in onCreate() method I need add to TableLayout certain number of rows and buttons for each row (for example 5x5, which means that I must add 5 rows and 5 buttons for each row) then I get something like square. This number I get from previous activity by intent . Then I need change size of buttons to maximum, depending on TableLayout width (which I get by ViewTreeObserver ), which is mach_parent . So size of each button will be btnWidth = btnHeight = (int) tlWidth / n . After

Creating and Adding dynamic views in Relative layout inside FrameLayout

感情迁移 提交于 2019-12-11 08:04:39
问题 What I'm doing is something like this <Dynamic Framelayout > <Dynamic Relaive Layout> <Dynamic imageView> <Dynamic TextView> </Dynamic Relaive Layout> </Dynamic Framelayout> I have created the layout and placed the views as I discussed above. But Now I want to textview should be placed below the image view here what I m getting. notice the RED textviews. this should be below the imageview and horizontally centered. Here is my Code. final FrameLayout main = (FrameLayout) findViewById(R.id.add

Android - add subview with layout params at specific index (in code)

六眼飞鱼酱① 提交于 2019-12-11 01:36:38
问题 I may be missing something, but I can't find a way to add a subview to a view at a specified index with specific layout params. There's addView(View v, LayoutParams lp) and there's addView(View v, int index) - but I can't find a way to specify both. What am I missing? 回答1: Why, there's a method with both: addView(View child, int index, ViewGroup.LayoutParams params) : Here. 回答2: Here is an example. I use it to show a progress indicator on any view. final ViewGroup rootFrameLayout = (ViewGroup