Android Studio - How to change layout - android-studio

In Eclipse, I can right - click on my layout (say LinearLayout) and click on Change Layout
In Android Studio, I dont see anything like that. I do see Morphing but that will now show up at all times. For example, if you create simple HalloWorld with RelativeLayout, if you right click on that Layout while in Graphical mode, Morphing will not show.
If you right click on a widget in that layout, Morphing shows but to change widget type, not layout type.

If you want to change the Layout, you can do Two things:
OPTION 1
1. Simply click into your Xml file and select the "Text" option at the bottom on your screen
2.Change to layout
OPTION 2
1.Just drag another layout in Design and put your items in it, delete your old layout PS. you can have layouts in other layouts
Hope I helped!

In Android Studio 3.6.3 the easiest way to change the Layout is to right-click on the layout in your Component Tree and click Convert view….

The other option is to delete this layout and create new activity layout with type you want to be.

You also can use AbsoluteLayout, just change RelativeLayout to AbsoluteLayout in activity_main.xml. With AbsoluteLayout you're more "free"

Related

Why does Android Studio never show layout decorations when I open it?

As you can see in the image below, every time I open a project in Android Studio, the layout decorations option is deselected. How can I have it selected for default?
look on the top left of constraintLayout that you currently open, click on the eye icon and then click Show Layout Decorations. then you will be able to see it. but i don't know how to access it.
I think is not possible. I never see about that the solution

Android Studio Widget, Text Field, Large, Medium and Small Text is missing all I have is Plain which gives a Name. How can I get it and others?

I'm looking at Youtube examples and I see the instructor has Widgets I don't have, Like different size Text Fields and an analogue clock.
Is there somewhere I can get more Widgets?
I obtained a text size same as to the "tutorial" using:
android:textAppearance="#style/TextAppearance.AppCompat.Large"
Looks like AndroidStudio has undergone some change. Best option is to enter the "Text" mode and type the style yourself. For ex. if you need an equivalent of LargeText view, then add a TextView and move onto the Text mode and add this line:
android:textAppearance="#style/?android:attr/textAppearanceLarge"
Or you could also edit the properties of TextView too.
You should add this line android:textAppearance="#android:style/TextAppearance.Large"
inside the TextView after clicking on the Text tab near Design tab located in the middle left to the right of design tab.
but you have to consider that first of all you need to drag and drop TextView from Widgets into the user interface or Design section.
Click into the Text tab located middle left to the right of the Design tab, find the TextView element and within it simply enter this line of code:
style="/?android:attr/textAppearanceLarge"
Remember this line of code has to be within the element in order for it to work.
Go to properties and then select text appearance and select app.
combat.large
Use this:
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
Add it inside your Textview tag.

Android Studio - view both Text and Design preview of layout

In Android Studio, how can I view both the text and design preview of an XML layout side by side.
I could see it by default when I installed Studio, but now that is gone,
and I'm not sure why. I can only see or the other.
How do I re-enable it?
Open your [whatever].xml. At the bottom you'll see Design and Text. Select Text. If you still can't see the actual layout, only xml, then select "Preview" which is located at the right of the window, between Gradle and Maven Projects.
Click on preview while text is selected.
At first, select your desired .xml layout from the Project tab then use Code, Split and Design buttons to switch between the views. (Android Studio 3.6)
Code - Display only XML part
Split- Display XML and design both
Design- Only design part
It appears that in Android 3.6.1, the buttons to select Design, Split, or Code have been placed in the upper right of the XML layout screen.
Select any one from the top right options to change the view of your Code and Design
You can split the tab by right-clicking on the tab and selecting either Split Horizontally or Split Vertically. Then, you can select the Design tab on one and the Text tab on the other.

Switching TabHost Tabs in Android Studio UI Designer

How can I switch between the tabs of a TabHost in the UI Designer for inserting content? Is there a keyboard shortcut or something else
I found a way to visualise any tab using TabHost in the UI Designer. Is probably not the best way, but it works.
1. Go to the Component Tree, where you have all the elements of the UI.
2. Inside the FrameLayout that TabHost automatically creates for you, there are the tabs.
3. If you change the order of the tabs just drag and dropping in the Component Tree, you get to see the one that is placed in the first position.
UPDATE:
According to this answer there is no way to change the tabs of a TabHost. That question refers to IntelliJ; I don't know if it applies to Android Studio.
Also, it seems that TabHost has been replaced by FragmentActivity and ActionBar. See Android how can i replace the deprecated tabhost? for a discussion.
It is defined as "Select next Tab in multi-editor file" in Settings -> Keymap.
On Windows it seems to default to CRTL+SHIFT+RIGHT/LEFT or ALT+SHIFT+RIGHT/LEFT. On my Mac it defaults to CTRL+SHIFT+RIGHT/LEFT.
Note that Studio doesn't allow the default Keymap to be edited so you will first need to copy the default and give it a new name.
Also see Shortcut to switch between design and text in android studio.
By mouse, select the FrameLayout then long left click on any space in it.

Android UI: Button with shape inside?

I need to create a button that looks like this:
button
I was hoping to create it without using images. To create the pink part, I wanted to use a drawable.
How can I include a shape drawable within a button?
You can create a Layout, set background color for that layout as you wish. In that layout add two textviews. Set background for one layout pink. add another under the first textview. Then you can set onClickListener on layout. It'll work same as that of button and it'll be easy to change colors and text programatically.
Try using an ImageButton and setting android:src to point to your ShapeDrawable resource.

Resources