android-layout

How to get all Buttons ID's in one time on Android

旧时模样 提交于 2020-06-24 07:37:41
问题 I have 16 Button s in my Activity and I have to initialize those inside onCreate(). Is there any way to initialize all buttons in one single line code?(loops etc.) Code should take all buttons R.id. from XML Layout and process.... 回答1: Let's say you named your button button_0, button_1, .. button_15 . You can do: for (int i = 0; i < 16; i++) { int id = getResources().getIdentifier("button_"+i, "id", getPackageName()); button[i] = (Button) findViewById(id); } 回答2: Well, if all 16 of those

How to group multiple views in a ConstraintLayout

回眸只為那壹抹淺笑 提交于 2020-06-24 05:02:45
问题 I have added 3 buttons in a ConstraintLayout. I have added a button to disable or enable these buttons. If I was using normal LinearLayout. I could have put all the buttons in a Linear Layout and enable or disable that particular layout. But I am using ConstraintLayout. So I need to disable or enable all of these buttons, I believe that there must be a way in ConstraintLayout to group different views. Kindly guide me how to group views in ConstriantLayout <Button android:text="Button" android

IllegalArgumentException When trying to use @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox

浪子不回头ぞ 提交于 2020-06-23 16:00:26
问题 I am trying to stylize the TextInputLayout with an outline. But when I try to use @style/Widget.MaterialComponents.TextInputLayout.OutlinedBox in style attribute my app crashes with this exception: Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant). Here is the TextInputLayout theme I want to use OutlinedBox It was working fine but suddenly this error appeared during development <style name=

FATAL EXCEPTION: main Process: com.goom.project_532, PID: 25054 android.view.InflateException: Binary XML file

独自空忆成欢 提交于 2020-06-21 05:45:20
问题 In my scenario, I am using custom seekbar module and I have fragment_one_control and fragment_two_control both xml file I am using. Here, fragment_one_control to using include tag and referring fragment_two_control. Then from fragment_two_control I am calling my custom module seekbar. Here, Android 9 and below version working fine but I am getting crash in Android 10 . How to resolve it? Crash Details 2020-06-13 15:36:44.462 25054-25054/com.goom.project_532 E/AndroidRuntime: FATAL EXCEPTION:

What is the difference between match_parent and fill_parent?

China☆狼群 提交于 2020-06-19 01:33:30
问题 I'm a little confused about two XML properties: match_parent and fill_parent . It seems that both are the same. Is there any difference between them? 回答1: They're the same thing (in API Level 8+). Use match_parent . FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding) ... fill_parent : The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced

What is the difference between match_parent and fill_parent?

让人想犯罪 __ 提交于 2020-06-19 01:26:51
问题 I'm a little confused about two XML properties: match_parent and fill_parent . It seems that both are the same. Is there any difference between them? 回答1: They're the same thing (in API Level 8+). Use match_parent . FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the view wants to be as big as its parent (minus padding) ... fill_parent : The view should be as big as its parent (minus padding). This constant is deprecated starting from API Level 8 and is replaced

Query in image size in android studio

南笙酒味 提交于 2020-06-17 09:10:48
问题 Hello. There is a ball image of 640X480.In the image, as you can see I have specified layout_width as 849px and layout_height as 680 px.I have taken a background colour of blue.As layout_width specified is much more than 640px(width size of image), then why the image's left side and right side is not surrounded with blue background.Image's top and bottom is surrounded with blue background. XML Code: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout

Query in image size in android studio

杀马特。学长 韩版系。学妹 提交于 2020-06-17 09:09:54
问题 Hello. There is a ball image of 640X480.In the image, as you can see I have specified layout_width as 849px and layout_height as 680 px.I have taken a background colour of blue.As layout_width specified is much more than 640px(width size of image), then why the image's left side and right side is not surrounded with blue background.Image's top and bottom is surrounded with blue background. XML Code: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout

Android ImageView Displays on Emulator but not on Device

旧巷老猫 提交于 2020-06-14 21:13:31
问题 I am working in AndroidStudio trying to set an image to display on the screen after it is taken by the camera. This is working flawlessly on the emulator but when I test it on my device (Nexus 5) the image does not show up. I have tried scaling down my image which didn't work, I also tried using a small image in my drawables folder to make sure it wasn't a file path issue (the drawable image also displayed on the emulator but not on my phone). I also tried converting the bitmap to a drawable

Android Studio loads incorrect content in many files

瘦欲@ 提交于 2020-06-13 09:38:33
问题 When I create a new project, many files are being generated incomplete like colors.xml, mipmap files and many more. Already tried the following:- Invalidate cache and restart. Deleted temp files from my PC. Uninstalled Android Studio and reinstalled it but after some time the same problem occurred again. I am attaching Images to some files which are incomplete Please give some suggestions or anyone else who had the same problem can help me out. 回答1: Follow these steps:- Close the Android