TextView is being cut off in CardView? - java

Good Afternoon, I want to build a Card View with information but everytime I try to build it, the last part of the text gets cut of even though there should be space.
XML file:
I have attached an image on what the issue looks like and don't worry all the information in the photo is fake, is there something I am missing from my layouts that is cutting the text a bit earlier than it should be.
Edit:I have fixed it.

It depends on the height of the cardview or "dropdown_printer_setting" linearLayout. Try putting wrap_content.

Add a constraint layout inside of the card view then add in the other views as child elements.
Also why do you have a fixed height for the card view ? try increasing it to fit or wrap_content. the 120sp you could also try changing it to dp as sp is usually used for text size

You should try and increase the height of the card view from 120 to at least 150dp and not sp, this should fix your problem

Related

Android GridView wrap_content cell width and dynamic number of items per row

In Android, how do I create two GridView(s) (or the supposedly better RecyclerViews) to create something that looks like this...
...where the number of items/cells per row will vary depending on the text length and both views should not be able to scroll independently (ie. the rootview would probably be a ScrollView and it will provide the ability to scroll).
I've tried GridView for the most part but I can't make the cell width wrap_content property to work.
Thanks.
You can use tag view for android using that you can create view as you want.
see below library for more information
https://github.com/whilu/AndroidTagView

How to add textview small texts

i want to make a program. I have 16 textviews that includes letters. And i want to add small text to every textview -programmatically-. Please refer to the pictures..
firstly --> picture
after adding --> picture
You may do this:
Instead of getting textviews into the program, you can create a layout file which contains 2 text views. You may need to use "layers" to do this. One for big text, other one for the little text which contains the reduced size texts. Then inflate the layout file to a view by an inflater. Then use that view instead of textview. So you have little numbers on you table now.
I don't know about RecyclerView, may be that can be a better solution but as i said i dont know it so here is my answer, good luck at your project!

Android ListView: Fixed number of rows for EVERY screen size

I have to create a listview inside a fragment that should always display the first 3 items no matter what screen size (rest should be scrollable). These 3 items should fill up the whole available space, which means that the item height has to be adjusted dynamically. You could also say: The first three items should take up about 33% of the listview each.
Is there a way achieving this using LinearLayout and layout weights? If not, what would be the best way to to this programatically, e.g. by determining current fragment size or something like that?
I managed to get the height and width using OnGlobalLayoutListener.
After all, we decided this wasn't a good idea layout-wise, but I thought someone might find this interesting nevertheless ;)
Try using the view.setMinimumHeight(int) on the inflated layout in your list adapter and supply it with a desired height.
As for obtaining screen size you can check this SO post
Edit: Apply that method to the layout that defines each item. You need a custom adapter and do that work in your getView method
You could probably calculate the size on the fly by determining the screen size, and adjusting the height of the list items as they are created & added to the list. This question and this one might help shed also shed some light on using weights, and would clean up your code.

How to handle a large textView that get's cutoff on small screen sizes in Android?

I have a textView that fits perfectly on my Galaxy Nexus and it takes up the whole screen. I'm trying the application out on lower resolution devices and my text is getting cutoff. What's the easiest way to alleviate this?
Stick it inside of a ScrollView.
EDIT: If you can't use a ScrollView, something like this might help. Basically, you would extend TextView and it would recalculate the text size whenever the size of the view changes.
If you can't put in a ScrollView or make in 2 lines, another option is to have a different smaller text for lower resolutions.
You can do this on java by writing with \n it will gets new line.it automatically looks like scroll view.

Android layout in java code

i'm making an app that requires indefinite textviews and images. i'm trying to implement a Pulse News app UI but having a hard time implementing one. so i thought of an idea to make a UI like that with the use of textviews, imageview and horizontal scroll view.
textview string values are from parsed xml online and images or the imageviews will be images from a specific directory in the sdcard that my app is using.
can anyone give me ideas how can i do it without using an xml layout or is there any or other options or ways for doing this? thanks...
You can create a viewgroup with one textview and an image. Then it can be added dynamically to your layout many times. This can be done by creating objects in a loop. You can change the content in each viewgroup at the time of inflation.
though i dont know what exactly how pulse new app looks like, but by going through your question (horizontal scroll view in particular) I guess you want to implement a "Gallery" type implementation where in you can swipe left/right on page basis.
If my assumption is correct then you will like to see to ViewPager of android backward compatiblity pkg.

Categories