Design view in Android Studio scrunched to the left - android

Hopefully this is something simple and stupid. I am editing an existing Android app for an embedded device that communicates with Bluetooth. The manufacturer of the development kit provides the Android code so that you can edit it how you want. The device (Silabs Thunderboard Sense 2) just transfers numeric information (sensor data) from the device to the phone.
I have been able to edit the actual code to change labels and values to what I want, but now I want to rearrange/add/eliminate some buttons in the screen layout. The app generates these buttons when downloaded to the phone, but I'm unable to see them when I open the .xml files in "design view" in Android Studio. At first I thought the buttons weren't there at all, but then I noticed that there is a blue line down the left side of the sample screen. When I click on it, I get the attributes etc., but no matter what I try, I can't seem to get the button to show. I have tried pulling it, double-clicking it, right-clicking it, changing attributes...nothing works. I'm thinking that it's a setting that needs to be tweaked, but I'm afraid to just go changing everything and making it worse. Here is what it looks like:
the red circle indicates where the mysterious blue line appears.
It's like the image is scrunched to the left with no width. It should be a square image button with a small icon, a label and some live data. Any ideas?
Don

try setting the FrameLayout width policy to match_parent.
EDIT
Also check your parent LinearLayout width and height policy is `match_parent'.

Related

Why does my UI Button works in editor but not in android after being built?

I have an annoying problem with my project on Unity2D. I have created a shop GUI, with buttons to purchase hats.
However, 4 out of the 6 hats buttons are working for some reason in the android build. Whereas for some reason all of them work in editor mode...
They all are in the same Canvas.
For some reason, I moved the button a little bit up, next to the seagull and they seem to be working when I do that. But I want them to work on my shop GUI like the other buttons :X
I don't have anything transparent blocking the buttons by the way (And if I did, it would not work in editor mode as well, right?)
I already tried to
- Move from OnClick() to Event Trigger Pointer Down (no success)
- Change Drag Thresold in the event manager.
- Check Force Active in event manager.
- Redoing the buttons that are not working from scratch...
I'm really clueless, and I need your help!
Some screenshots :
The Canvas containing my buttons
Green are working buttons, red are not working, and orange is selected (work in editor) see bottom right corner
[2
for some reasons try placing your button as the lowest index siblings in the hierarchy so that no other UI element overlaps them.
Secondly try using reference resolution as 1080 X 1920 with match factor as 0.5

Android .xml File Doesn't Match Emulator

I have created an extremely simple example of my problem. In this app there are two buttons (neither of them do anything just supposed to be there and be able to be clicked). In the .xml file I have the Pixel phone selected and have laid out the buttons to fit the screen correctly (using match_parent for width) (.xml file). But when I run the application on my Pixel emulator (not edited at all) only second button shows up and the width isn't right (Emulator). This feels like it has to be operator error considering the extreme differences. Any ideas?

layout on android studio preview doesn't look the same when running the app on the phone

im developing an android app on android studio, when i run my app the layout looks a bit different from the preview as well as on other phones,
for example: the buttons are in different order (from right to left instead from left to right) or other changes similar to this.
as well as on some phones the layout doesn't fit perfectly on the screen for example: the buttons on the sides of the screen appear to be cut out.
how can i fix it so the app will look the same with every phone and not only some of them?
About the Right-to-left/ Left-to-right, you can choose the globe icon in the preview options bar frame and then choose Preview Right-to-Left Layout option. This will "fix" the buttons order in preview.
About the buttons that appear to be cut out - make sure you use dp units instead of pixels. You can read more about it here:
http://developer.android.com/guide/practices/screens_support.html
Make sure you check if you have used the constraints on your components properly. Usually that's what makes the layout messy after running the app on your phone/emulator, even tho it looks perfect on your XML file.

how to make app stretch to all phones android studio

so I'm making a really simple app that just shows some buttons and images,
it looks great on the simulator (because I guess that's the resolution I've been working on ...)
but when I try to build it to my phone it looks differently (the buttons are more stretched out and there is allot more background space in between the buttons and the end of the screen,
I guess it's something that's suppose to be simple but how to I make my app "zoom stretch" to the phone content it's going to be on, meaning it will look the same on any phone and if necessary will stretch the image a bit to fit the screen ?
Thx
In your XML, its important to not use specific(dp,px,etc.) sizes for laying buttons/text boxes/etc. out. For example, for a button thats on the page, use a "layout_width" of "match_parent" and add padding (if necessary from there). This will allow your button to stretch properly without having that extra whitespace.

Dynamic Layout android

I'm new to Android and it seems that I cannot find the right layout for my problem.
I have a bunch of buttons (also added dynamically during the execution of the app) that I want to display in a column.
I have used a LinearLayout (Vertical) and it does the works pretty well in a tablet. The problem is that on smaller screen, like phones, there's not enough space to visualize all the buttons and half of them are not shown.
Is there a layout that allows me to do either something like "show all the button in a column, and then when there's no more space, start piling up in the next column", or something that allows it to resize the buttons in order to fit them all onto the one column?
I have tried with GridLayout but with no success (i.e. even setting the android:columnCount=3 I didn't notice any change)
Any ideas?

Categories

Resources