Android layout with vertical tabs - design like hello sms app - android-layout

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

Related

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.

Can't form a chain between two views/widgets in Android Studio

When I'm using the layout editor in Android Studio and I try to make a chain (bidirectional constraint) between a EditText View and a Button View using the constraint anchors, it doesn't make the chain.
It only makes a constraint if I try to constrain one View to the other.
I am trying to chain the right side of the EditText to the left side of the Button.
This is what my Layout Editor looks like:
I was trying to figure this out too. I've discovered that one way to do it is to select both views, then right click and select Center Horizontally. This creates the chain, but then you have to adjust any other constraints accordingly. I'm new to Android, so I'm sure there will be other ways....
I had the same issue. Solved it by going in into the XML as instructed by the tutorial:
https://developer.android.com/training/basics/firstapp/building-ui.html
On the tutorial, click "See the final layout XML" and compare. My XML was missing:
app:layout_constraintLeft_toRightOf="#+id/editText"
In Android Studio 3.0.1, choose the two objects (on the xml design tab) and right click on one of them and you will have under "chain" option two options: one to chain horizontally and second to chain vertically.
I got a solution, probably will not be the best one until someone really answer properly, but works.
I hope this helps others guys who stuck in the same place as me, so you can continuous the work.
Looks like the interface of android studio is not working properly when came to create chains. Some options from people here work for like 2 or 3 elements, but I has 5 elements.
So the answer is solve this in the code XML.
My steps are for Horizontal arrangement, if you wanna vertical just change Right/Left for Top/Bottom
I put all the elements in the place that I want and remove all connections. (Than in my case I connect the top and bottom so they can be in the middle.)
Then I connect the first element in the left and the last element in the right.
And connect the right of each element in the left side of the next element.
app:layout_constraintRight_toLeftOf="#id/right_element"
Image of elements connect normal, no chain yet
After that I go inside the code and put manually the connection to the left element.
app:layout_constraintLeft_toRightOf="#+id/left_element"
And the chain was created.
Image of elements connect with chain
I hope this help, sorry for don't post the pictures, I don't have reputation enough yet XD.
i think android studio ui editor need more improvement for creating chain currently i am using Android Studio Preview 3.0 Canary 3
Sometime from editor it works perfectly but sometime it not, when linking not happen from ui editor we need to add constraint manually as per requirement Vertical or horizontal chain following are constraints
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf
and also we declare chain style manually in XML as follow
layout_constraintHorizontal_chainStyle or layout_constraintVertical_chainStyle
CHAIN_SPREAD -- the elements will be spread out (default style)
Weighted chain -- in CHAIN_SPREAD mode, if some widgets are set to MATCH_CONSTRAINT, they will split the available space
CHAIN_SPREAD_INSIDE -- similar, but the endpoints of the chain will not be spread out
CHAIN_PACKED -- the elements of the chain will be packed together. The horizontal or vertical bias attribute of the child will then affect the positioning of the packed elements
hope android studio editor will improve this
I worked out that in Android Studio 3.2.2 you have to click on the views in the component tree, so left click first component and then holding shift click the second component and then right click and in the menu you will see chains as in my screenshot below.
Android Studio 3.2.2
Resolved by adding constraints in both edit text (app:layout_constraintRight_toLeftOf="#+id/button") and button (app:layout_constraintBaseline_toBaselineOf="#+id/editText")
Complete example as below
<EditText
android:id="#+id/editText"
android:layout_width="245dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:ems="10"
app:layout_constraintRight_toLeftOf="#+id/button"
android:hint="#string/edit_message"
android:inputType="textPersonName"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_marginRight="16dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBaseline_toBaselineOf="#+id/editText"
app:layout_constraintLeft_toRightOf="#+id/editText"
android:layout_marginLeft="16dp" />
The way I have been able to create a chain view in the blueprint layout is by drag click, select the objects to be linked. Then while they are selected right click and select "center horizontally" After doing this I can then create the other constraint and chain
This can specifically be resolved by holding the shift button and pressing both of the widgets. After this process, you can then right-click one of the widgets to be able to chain the views. Use this for the EditText View as well as the button particularly.
I solved this by creating the chain in blueprint mode. The tutorial never says you have to go back to it but if you do you can create the chain.
Just a tip when following the tutorial is to make sure that the Android Studio is upto date. I was wondering where certain buttons are when following the tutorials but found i was using an older version.
In terms of the question, the best is given by James # 6/6/17.
Add three buttons into the view
Select them all and right click
Select "Center Horizontally"
This does the trick to create the chain
I disobeyed the tutorial by turning on Autoconnect (because I was trying everything).
I selected both widgets, then selected Center Horizontally. The chain was created, I turned Autoconnect back off, then continued the tutorial.
The DESIGN tab is very prone to bugs!
Just do what you'd want to do in the design but write it via XML. No need for tutorials it's self-explanatory, connect all the lefts and rights!
I had the same problem before, and from what I can I tell, we have the same problem.
The tutorial expects you to use android studio 3 version. When I got this problem, I realized that my android studio still 2.2.3. After installing the update for the version 3 and sdk etc to the latest version it worked.
Hope this helps.
what caused the problem for me-
i duplicated one of my views in my layout (to speed things up- or so i thought).
by doing so - i caused the problem - several views had the same android:id value.
which is a big no-no.
a unique value to all my view (by changing the android:id ) helped fix this problem
I was having the same issue as well and what worked for me was selecting both views while holding the CMD button instead of the SHIFT button.
As a reference, I'm using the macOS version of Android Studio and was selecting both views using the SHIFT button which resulted in Chains being grayed-out.
I hope that helps somebody!

Adjusting content to layout frame

I just started learning how to develop apps for android. I have a seamingly easy question but I couldn't find an answer to it.
I'm trying to do the opposite of what wrap-content does (in the context of an image button).
I want my content to adjust to the frame of the button, whereas wrap-content matches the frame to the content.
Is there a way to do that? It sounds easy enough but I couldn't figure out how. Thanks in advance!
EDIT : I think I've expressed myself poorly, sorry.
What I really want is to be able to resize the frame of my image button, with its content adjusting by itself to the frame, instead of having the button crop around a static picture.
Use match_parent
From Android documentation:
Match Parent: Sets the dimension to match that of the parent element. Added in API Level 8 to deprecate fill_parent.
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

How to have multiple layouts in one activity in android?

What i want in my activity is two buttons on the top in one single line.. and below that i want a framelayout in which i want an imageview and i wil add my custom view on the top of imageview. I tried a lot but i am having a lot of confusion.
Shown in the image below is somewhat like i want.
I want to use framelayout because i want to add my custom view over my imageview. But if i add button on framelayout it comes above the image. It is getting really confusing and messy for me.
I did'nt know that we could nest two layouts in a single activity. I nested LinearLayout with FrameLayout and my problem got solved.. Cheers!

layout_width and android:layout_weight manipulations with gaps (margins) and paddings

The combination of having, for example, two buttons in some layout with
android:layout_width="0dip" android:layout_weight="1"
properties works just fine, both buttons will occupy equal space!
But what if I want to have 2 buttons but also a space for one more, and that space to be equal like the space the buttons will occupies.
Put in other words, I want to have a buttons with
android:layout_width="0dip" android:layout_weight="1"
properties and a space on the right of the buttons that will act just like invisible button with android:layout_width="0dip" android:layout_weight="1" properties
Is there a clean way to do this ?
I do not want to do hacks like textview with no text on it and android:layout_width="0dip" android:layout_weight="1" properties ...
I want to know is there way to put 'weight' on the margins or to the paddings.
I think there is no such a thing but I want to hear your opinion and your suggestions for this kind of layouts, that shrink depending on the screen width.
You should look at the weightSum property.
If you place the 2 elements in a horizontal LinearLayout, each element with layout_weight=1, declare the weightSum=3 of the LinearLayout, this should result in exactly what you need.
Also, if you decide to hack your way through this, check out a Space view - its a lightweight view for such cases.
This isn't exactly the answer to your question, but you can set a button to visibility "INVISIBLE" (as opposed to GONE), and it'll be invisible but still occupy the same space.
Otherwise, try making the layout_weight of your button half the weightSum specified in the containing layout and align your button to the left. If it doesn't work, and you don't like the solution in the first paragraph, you can just use a View as a spacer item.
use android:weightsum=100 in main layout and whatever the size u need for the buttons divide the sum into that number of parts and there in your buttons use android:layout_width=" ". It automatically sets the spacing and the size of the buttons.

Resources