Trouble Dragging Android Views - android

I'm trying to learn Android development and using the Android SDK in Eclipse. I'm following a tutorial to build the Main.XML file on the Graphical Layout tab. It instructs me to drag several Views onto the screen surface, including: EditText, Button, RadioGroup and RadioButton.
My issue is that these Views do not seem to drag. I place the mouse cursor over them, press the right button but the Views are not captured for dragging. There are other Views (such as Gallery) that seems to drag OK but those I'm interested in (to complete the tutorial lesson) do not drag.
Any help making this work properly would be appreciated.

Forget about dragging Android elements. The best approach is to hand code them. Eclipse helps a lot, since it can show you a preview of what you wrote.

you can try to edit the properties of the button i do believe that eclipse lets you do that

Goto Help->Check for New Updates and update
And then, You'll be able to drag n drop the View components onto your xml Graphical Layout. As #MEGA said, its advisable to hand code them. But, still as a beginner, I use Graphical Layout and the set properties using the Properties tab, which is more handy (since we donno what each property is for!)

Related

Get the Xamarin Android Designer to work with the Toolbox

This question is about Xamarin Android which supports drag and drop functionality, not Xamarin Forms.
When using the Xamarin Android Designer in Visual Studio I am only allowed to drag in one control from the toolbox. After this, I am no longer able to add any new buttons (with the cursor changing to a "not allowed" symbol when trying to drag in a new button).
Steps to reproduce the problem:
Create a new Xamarin Android App project in Visual Studio.
Navigate to the "Resources/layout/activity_main.axml".
Try to add two buttons to the Design. Trying to add the second one will show the "not allowed" symbol in place of the cursor.
I've looked online for a solution, including Xamarin Community Forums and the Visual Studio Developer Community and but have only found posts on the same or similar issue with no solution that has worked for me. How can I solve this?
RelativeLayout in Xaml doesn't allow drag&droping more than 1 control by design.
RelativeLayout is a ViewGroup that displays child View elements in relative positions. The position of a View can be specified as relative to sibling elements (such as to the left-of or below a given element) or in positions relative to the RelativeLayout area (such as aligned to the bottom, left of center).
Basically, designer let you add only one control on which you design your interface. You position the other controls from Xaml based on original dragged control.
You can drag&drop controls from toolbox directly to Xml code and it allows you to edit further the control from Properties box.
Also, https://developer.android.com/guide/topics/ui/layout/relative officially recommends to use ConstraintLayout instead.
If you insists to use RelativeLayout, you will have to code the interface in Xaml.

Buttons not visible on the application. What's wrong?

I created an empty activity for 'My Testing App' and it looks like the following in the preview section:
But when I generated a build apk and used the same in my cell phone the result was like the following:
I can only view the exit button on the very top left but the two other buttons, that should be above it are missing.
I tried to rearrange the icons on the screen as well. I made them to go to the bottom, to the right most, but I see no change when the apk is reinstalled.
How do I make them visible on the hardware?
Here is the snap of the code for this activity:
To quickly add constraints to your layout just click on the Infer Constraints button in the Layout Editor toolbar. Learn more about the feature here: https://developer.android.com/training/constraint-layout/index.html#use-autoconnect-and-infer-constraints
Right Click on you Layout and select "Convert View" Option.
then select "LinearLayout" Option.
it will show all three buttons in the output.
You have to learn about ConstrainLayout in Android
View in ConstrainLayout is not only drag and drop. You should link the constrain line in each view to reference with somewhere on the screen.
Any XML attributes prefixed with tools are removed when the app is compiled and are only rendered by Android Studio layout editor.
You need to properly set constraints in your ConstraintLayout, not use absolute positioning.
Or you may instead use RelativeLayout, LinearLayout, etc.
https://developer.android.com/training/constraint-layout/index.html
Start by reading this. Most of what you need is answered here. The problem is that your views are not properly constrained (basically they aren't linked to anything so when you run your app it doesn't know where to place them and just defaults to the upper left).

How to get insights of app

I am beginner in android app development, I would like to know that how can i get insights of something that has been implemented, Which layout is used, Which view is it, I try to make some attractive UI and i end-up with some ugly UI, I would like to know how they make UI like this
Which layout they use, Which view they use, I Want to know this insights so that i can learn about them and implement the same in my app.
You can do it this by using Dump View Hierarchy for UI Automator option in Eclipse for that
Go to DDMS and devicesand select the device
and then it's generate your device screen shot .uix as below
Move your Cursor in uix and you'll see the all View Hierarchy Structure in right side upper corner area.
Here you'll get idea about the Layout View only.
#Pushpendra you will never get exactly what you want, you can get some ideas by seeing some existing application and then google it or check some open source projects on github to get starting idea.
You have to use your own creativity.
Here is a basic example to help you start.
Use this library
cardslib
which will help you to built card style layout as some of your shared images UI is designed the same way.
Sample app demo
for above library.
I hope it helps you.
If you want just to how the view is draw, you can go in the "Developer Options" settings and enable the "Show layout bounds" item.
If you want a more in-depth view of the layout, on the SDK you have the "Hierarchy View" that can be accessed from command line or on Eclipse/Android Studio. Inside Hierarchy View, go to the screen you want to know in the phone, select the screen in Hierarchy View and after a while the entire layout tree is shown and you can explore the items in it, so you can have an idea about the layout.

setting my main project default to linear instead of relative

Everytime I follow a tutorial book or you tube video, I have also used the cheat help in eclipse. My programming always comes out with errors. here is one example why does all the tutorials main activity comes out showing linear layout and my projects default is relative layout. So how do I change the default to linear when creating new project.
I know I can open a new layout xml but all the tutorials opens a new project in linear.
I am a massive fan of android and I really want to make some apps, but all the tutorials never seem to correspond with the results I get and they all make it look so easy.
go to youre layout.xml
make sure to be in the graphical layout (check bottom bar)
top-right in 'outline' right-click on the relative layout
choose 'change layout'
choose youre desired layout, (linearlayout(vertical) probably in ur case)
I found it after digging a lot in Android Studio After visiting JetBrains and Intelij documentation and help sections i found nothing much helpful but i found way on my own, I had answered it here, With all explanation and screenshots.

How To Move Layout Items After SDK Update?

I just updated my Android SDK/etc (Eclipse IDE) and, while there seems to be some nice, new aspects/features of the Graphical Layout part for xml's, the previous ability of moving items using the Red Arrows up/down is missing and I'm not able to move items around (in or out of layouts).
Yes, I know I can (and guess I'll have to) move the actual xml code around but, I really like the ability to move items graphically.
Am I missing something?
Thanks
I don't think you are missing anything. Whoever wrote the new plugin is though, see:
Layout Outline in Eclipse lacks Up/Down Plus/Minus buttons

Categories

Resources