Cannot view all Button attributes in Android studio. - android-studio

I actually wanted to the bottom right corner of the screen. But when i run it on the emulator, the button automatically shows up in the top left corner of the screen.
All i want is to view all the attachments available for button im Android studio 3.1

Are you working on Constraint Layout? If so, you need to add a constraint for the left side of the view to the left margin of the screen. By default, the view will fall to the left-top of the activity when it is created.
You could do this in the Design tab, or go to 'Text' tab and add the following xml code below the other lines of code for the particular widget:
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
If you are using Liner layout, then you need to set the layout_gravity property to: "end | top".
("End" means 'right' and "start" means 'left' - this is a convention for left-to-right languages. )
Hope this helps.

Related

This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints The

This view is not constrained, it only has designtime positions, so it will jump to (0,0) unless you add constraints.
The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX.) These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.
This may help someone.
I am using Android Studio 3.1 and i faced same problem but i didn't find these options (Constraint Layout -> Infer Layout) as suggested in the above answer.
Then after carefully checking i found "Infer Constraint" option above the layout window (refer to screenshot below in step 1)
Step 1: Click on "Infer Constraint". This may solve your problem, but if your widget still not visible (as in my case), then follow step 2.
Step 2: Click on "AppTheme" and select "NoTitleBar" theme as selected in the screenshot
This solved my problem.
Add the following piece of code to your code:
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Right click on design layout in Android Studio, then select "Constrain Layout" and sub menu is open, then select "infer Layout" and compile your App.
From Android Studio v3 and up, Infer Constraint was removed from the dropdown.
Use the magic wand icon in the toolbar menu above the design preview; there is the "Infer Constraints" button. Click on this button, this will automatically add some lines in the text field and the red line will be removed.
In my project this error was caused by android:layout_width="fill_parent" and android:layout_height="fill_parent" expressions. fill_parent constant is obsolete. Changing to to match_parent solved the problem:
<ViewFlipper
android:id="#+id/viewFlipper1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
</ViewFlipper>
Android studio hint says:
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints less... (Ctrl+F1)
The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX). These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor.
To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.
Good Work. Just make a little change, according to my experience, You have to CLICK the " Infer Constraint " (a magic stick button).To make Infer Constraint appear, Remember the Palette (button/image/text etc) which you dragged on the constraint layout (screen). You have to click the very palette and it'll appear on the top right side. Click that magic stick button and your error will be removed.
Here is my fix (100% working):
1, Please drag and drop the images that you entered in folder "drawable". Note to keep the original name
2, Click the play(Green Triangle) button
3, It shows an error please click on your image and right click> Refactor> Rename>
All place> Refactor and then run the application again> Restart
Note that the image name must not contain "-", "_"
When you run the app it will save the name to memory so just re-enter the image with your original name and then click Refactor> Rename> enter another name (must not contain any characters)> select All place(This will change the entire corrupted name to something that works better)> Refactor and rerun your application!
To position a SurfaceView in the center of the ConstraintLayout, using the holder setFixedSize, change layout_width to "wrap_content".
// setting holder
holder?.setFixedSize(640, 480)
XML
<androidx.constraintlayout.widget.ConstraintLayout
android:id = "#+id/player_view"
android:gravity = "center"
android:layout_width = "0dp"
android:layout_height = "0dp"
app:layout_constraintTop_toTopOf = "parent"
app: layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent">
<SurfaceView
android:id = "#+id/surfaceView"
android:gravity = "center"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
app:layout_constraintTop_toTopOf = "parent"
app:layout_constraintBottom_toBottomOf = "parent"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

Dragging functionality not working on Android Studio 2.3?

This is the Component tree of my application.
I wanted to move the textView to the center. However, we can do that manually setting the properties of that element in the Text tab. But I suppose setting the properties manually doesn't align the elements properly on the UI.
There should be some way to drag the elements on the Design page. But then, I'm not able to drag the textView to which ever position I want.
Can anyone tell me how do I drag the 'textView' to the center ?
Even I'm facing the same problem. But, aligning an element to the center can be done using this property android:layout_gravity="center"
You can choose which ever position you like.

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 - How to change layout

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"

Android layout with vertical tabs - design like hello sms app

Can somebody please help me out in designing vertical tabs like in the given pic(taken from hello sms app)
I'm not asking for a code snippet , so please don't ditch this question as a homework type. What I would want to know is the approach that I should take. Do I have extend the stock TabLayout or an existing tablayout with a few styles and UI customizations? Your pointers to the right resource would be of great help. Thanks
you can achieve this using multipane layout in android. on your right side create the listview fragment and right side implement details screen using fragment. if you wants to slide the left side listview use slidepanelayout.
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/slide"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<fragment android:id="#+id/leftpane"
android:name="com.example.package.left"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left" />
<fragment android:id="#+id/rightpane"
android:name="com.example.package.right"
android:layout_width="350dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_weight="1"
/>
</android.support.v4.widget.SlidingPaneLayout>
I think this will not be achieved by TabLayout as it only supports Horizontal Orientation.
But you can go with SlidingPanel with NavigationDrawer where you can design DrawerItemLayout as per your requirement and get the exact layout you want.
Please check links #1. & #2.
I think this can reduce your efforts and you can get your task done easily.
No, you dont have to custom any view. You can just
Use RecyclerView for avatars list. If an avatar is selected, just changed background of the selected item to black U shape as in your design.
Use a detail view to display your avatar information.
You cannot use TabLayout here as it would not be appropriate for your purposes. What you could do is to have two layouts - maybe linear (or relative) to basically split the screen into the top part with a layout_weight of maybe 2 and the bottom layout with a layout_weight of 8 (for a 20/80) split.
From here, it's just a matter of designing your layouts. It looks like your top layout holds something like a spinner widget. You could either use this or a list view object. Your bottom layout definitely holds something like a list view. You could implement your own list view widget with some kind of a design in each row or you could have an xml layout file and reference this in your ArrayAdapter. Really, your choices are endless. For the left part of your bottom layout, you could probably use a vertical LinearLayout to hold the images of the people in the conversation.
And also don't forget to hide the ActionBar - if you want that.
what I would do is to split screen in a given ratio into two parts. Insert a list view with an adapter into left hand side and use fragments for the right hand side. But using tables is not a good idea. Using Fragments will make the things way easier. Check this link for an overview. Look at 2.2 and 2.3 sections.
And for the right hand side, inside fragment, you can use another list view with images and text.
You can achieve this by using a NavigationDrawer and a listview inside this navigation drawer.
this listview will be using a seperate xml layout for its row. which will have that image views inside as shown in the screenshot.
This is not a listview, its just a sliding menu. Learn about the sliding menu and you can achieve the design that you want. This will help u. https://github.com/jfeinstein10/SlidingMenu

Resources