How can I add more pictures and text in a textview? - java

I want to add images and text in a textview.
My code:
txtViewNews.setText(" text "+VAR11+" text");
txtViewNews.setCompoundDrawablesWithIntrinsicBounds(R.drawable.a1a, 0, 0, 0);
It works. On left side there is the image and on the right side there is the text.
But I want to add another image and another text under the first image and text. But how?

Use layout managers. Like Linear layout with vertical orientation in a grid layout. Nested Layout.

Can't understand why you need this while you can add listview which will grow when additional row will get added. Simple.

Related

Add Double border to Text Field In Android App

I'm new to Android development. I want to know is there any way to add two border in a text field. one inside another so that When User provide Input the Inner Border turns blue or specified color?
Hint
You can create separate drawables for each
app the outer drawable to a linear layout and inside that linear layout put edittext and apply second drawable to that edittext

Vaadin - adding text on top of an image

I am building a custom layout with Vaadin and I have Images that act as buttons (with a clicklistener). However I also need to display some text and I would like to display it over the image, so inside the image really. Is this possible and if yes, how?
Image dayCourt = new Image(null, new FileResource(new File(basepath + "/VAADIN/images/9_Available_18_Available.png")));
However I also need to display some text and I would like to display it over the image, so inside the image really. Is this possible and if yes, how?
The most straight forward way to do this is to wrap Image and Label (with the text you want to place over the image) inside CssLayout. Then you need to add style name to the label. In your theme you need to set z-index for the Label (so that it floats on top of image) (see: https://www.w3schools.com/cssref/pr_pos_z-index.asp ) and position absolute to Label (see: https://www.w3schools.com/cssref/pr_class_position.asp) relative to corner of the CssLayout
Also, if your Image happens to be static content, i.e. you do not have need to change the image on the fly, you could have even simpler solution. Instead of thinking composite of two components inside CssLayout, you could have only the Label and set the image from theme resources to be the background of the Label (see: https://www.w3schools.com/cssref/pr_background-image.asp).

Android Wrap_Content

When I add a button and set the Layout_Width, Layout_Height to Wrap_Content. What am I referring to because when I do that. Also, I see a box expand to fit the content. What is that box? I know that box is not the layout because my relative layout is set to fit parents. So what is the container that hold the button and allows me to modified the layout of that container?
Wrap_Content will take as much space as required by the element, it has setted height and width for.
wrap_content simply means that it'll wrap the content whatever may it be. In your case, the content would be the text in Button.
For example, if you have a button with text Click Me, then it'll take only the space required to fit the text Click me into the button box.
If you increase the text size, the button will automatically increase to fit the text in it.

How to set background colour of view to fill its parent?

I have a TableLayout, creating this table:
And I simply want the background color to fill the space given, rather than matching the content (however it does extend horizontally?)
How would I go about doing this? I set the individual TextViews to fill_parent, but that caused errors...
Edit: XML is here:, as it's pretty big

Getting graphical buttons to line up in xml

I have a custom popup window with a custom image background in which I need to place three custom buttons with their own background images. I have only one set of images for all the components, so I want all the parts to scale appropriately. My question now is how do I make sure that the buttons line up with the appropriate parts of the background image of the popup window. I have been experimenting with all sorts of widths and heights and I can not make it look consistent on all my test devices. Can anyone give me some pointers?
EDIT: Just to make it as clear as possible, the image below illustrates the kind of thing I am talking about:
I want the graphical button to line up with the arrows which are a part of the popup window background image.
arrange buttons in an xml layout and set this view to your custom popup and you can set images to buttons from code.

Categories