I want to be able to add a text-messaging balloon every time the user revives data from a HttpGet, I want it so that it looks nearly identical to the default Android text messaging UI. I'm fine with all the code, I just need a way to create the UI and create another text balloon every time data comes back from a HttpGet request.
Thanks ever so much, for the answering this questions and I'm sure there's an easy way to do it, yet I've found no way by using the 'ole Google.
I am doing something similar for my app am doing the following to achieve it:
You will need a 9-Patch-Image (a stretchable PNG, see here) that represents the bubble. You want to make the part stretchable that does not include the corners of the bubble. You can create the bubbles using an image editor of your choice (I'd recommend a vector graphics editor like Inkscape). Then use the 9-Patch editor included in the Android Developer Tools to transform the PNG image into a 9-Patch PNG.
Create a custom layout file for one bubble. Create a textview inside it, and add your bubble as a background resource. (android:background)
Use an arraylist with a custom adapter to inflate and fill your items.
So far, this will give you identical bubbles as background for all messages.
If you want to get fancy, you can create different bubbles for participants, and use the setBackgroundResource method in your Adapter to set the correct background.
Further, if you wish to align them left or right, like in the message app, you will need to add spacers to the left and right of your TextView in the layout file. I used FrameLayouts with a fixed width. Make sure to set their visibility to GONE.
As with swapping the different bubble colors, just set the visibility of the left/right spacer.
Related
I am fairly new to android studio and I am trying to make a car rental app for a university project.
I designed an app which has a horizontal slider containing blocks of different cars however I am unsure on how I would do this, I understand how the slider works and how to add elements to it.
I have a linear layout within the horizontal slider which will contain all of the blocks but I am unsure how to make a block of elements. Within the block it should have two buttons, an image and some text. Here is a picture of the design.
As you can see the available blocks are surrounded by a square. this is what I want, a small container which surrounds my data. Sort of like a div box in html.
Is there a way to do this?
Please just point me in the correct direction!
Many thanks!
It seems like cardviews can handle most of the grouping you want to do. I would reccomend looking into them because they incorporate a lot of material design components right out of the box.
https://developer.android.com/guide/topics/ui/layout/cardview
I want to create a sort of inline list of clickable text blocks in Android Studio. Below is the closest image I could find to the effect I would like. How would I achieve such an effect?
The information shown will be just a string, however clicking on this will take the user to another activity. It would be good if the text blocks also had a background, by the looks of it this app uses an image as the background, which should be fairly easy to set if the list is made from text views. I just don't know how to make a list with variable length inline objects.
See here: https://github.com/google/flexbox-layout
What I was looking for was specifically a horiztonal, wrapping, inline list.
I have a mock up that I want to create for when I'm switching between views in a viewpager.
The filled in circle would be indicative of a previous page, the semi-filled in circle would indicate current page and the last couple of empty circles would be the upcoming pages not currently viewing.
I was wondering where can I get started on how to create something like this?
I was also wondering how would I know how many pages are left to be viewed set that equal to the number of empty circles to show.
How would I be able to move along the circle images when swiping between views?
Thanks.
You dont need to reinvent the wheel for it so you can use library with little modificaiton in its source code.
use the library
https://github.com/JakeWharton/Android-ViewPagerIndicator
library have CirclePageIndicator which is performing the thing you need setting current circle as you scroll pages in ViewPager.you will need to add code to below class to drawPrevious circle in onDraw method.you can do that by storing previously selected page in variable and draw the previous page indicator as per your need.
https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/library/src/com/viewpagerindicator/CirclePageIndicator.java
I am trying to create a top bar for my app that shows the users level, coins. So i have an image view that displays the coin icon and a textview that displays the number of coins, if the number gets high it overlaps the image rather than pushing back the image and keeping everything aligned, is there a way to do that?
Without knowing your layout XML this is pure guesswork, but I'm assuming these two views are in a RelativeLayout. If so, add to one of them an attribute like this:
android:layout_toLeftOf="#id/otherViewId"
Options available are layout_toLeftOf layout_toRightOf layout_above and layout_below.
Post your layout XML and I'll update this with a better answer!
If you are using the relative layout then you can use the z-index attribute of views to manage the ordering.
I have an Activity that consists only of a huge EditText, full screen.
To match with my app's colours, i changed the background color of the EditText. But although it occupies the whole screen, it only changes the first line. Everytime i press enter i go to a new line and that line gets the background i want.
What propertie can i set in order to do this? I just can't see it!
I would wrap the EditText with a View and set the background color on the View.
In order to change the background of those Views that come with a background already, its better to provide your own image, and then use patch9 for proper resizing
I hope that helps
#everyone:
While searching for a solution for this same kind of problem i found this page. While reading the solutions i thought to myself: "There must be a better way to do this, instead of making your own styles and widgetborders, etcetera, etcetera, ....
Therefore, i present to you: the 1 LINE OF CODE SOLUTION!!! No trolling.
<your-widget-component-that-has-a-background-color>.getBackground().setColorFilter(Color.<your-desired-color>, PorterDuff.Mode.MULTIPLY);).
It works like this:
"getBackground()" fetches the background from the component
"setColorFilter" will call a filtering on the background image itself
"Color." determines what color you want to pass onto the filter
"PorterDuff.Mode." sets the kind of manipulation you would like to do with the given color and the fetched background image. People with knowledge of image editing software (GIMP, Photoshop, ...) might recognise these modes. Basically, each mode has a certain effect on how the color is applied to the background image. to simply "override" the color of the image, while preservind it's gradients, borders and such, use "MULTIPLY"
I haven't profoundly read the PorterDuff class documentation, but honestly, ain't it a powerful bit of code?
With kind regards,
How to set the background color of an EditText widget:
editText.setBackgroundColor(Color.RED);