Check if a TextView text is cut off the screen - java

I have a calendar view which is based on a GridView.
It basically a school tests calendar. When you click on one of the cells you can see information about the test. In some phones the TextView containing the information is not shown, or partially shown because the calendar catches the whole screen.
I decided that if the TextView is cut off, I want to show an AlertDialog instead of showing the information on the screen.
The problem is, I don't know how to check if the TextView is cut off.
Here are 2 pictures to show you what I mean:
Thats how it should look:
Thats how it sometimes looks:
Thanks!

You can find out what is screen size category (small, medium ...) see here, and then can have different behavior for different screen sizes. In your case you can show AlertDialog in case of small or medium size screens.

I have found a solution on my own.
I checked the height of the GridView and the height of the TextView.
then,
if (gridViewHeight + textViewHeight >= containingLinearLayoutHeight)
it means that the Text is cut off.

Related

Combining TextViews + Image to make a full Image/file

I have been asked to design an app that allows the user to take an image. At the top of the image there should be data such as imageNo and workOrder.
At the minute, I have two TextViews at the top of my activity, an ImageView below and then a green button at the end like so:
ImageScreenshot
When I click the green button I would like to send this full screen, textviews and image all as one file/image to a destination - like a screenshot.
Is there any libraries out there or does anyone know how I could achieve this?
Thanks!
https://www.youtube.com/watch?v=sPvCEsGm8us
check out this tutorial, I think it covers the basics of the question you asked. I automatically thought of this reference as I read your query.

XML Preview looks different than in device

As written in the topic, I have an android App, which has a design - that design is being shown differently on my Phone than in the XML-Preview.
Screenshots:
As you can see on my device, the button at the bottom is far more in the top than it should be. Any fixes?
This is because of the screen size. If you are just stacking the views in a LinearLayout they will take up whatever room they need and the the bottom will be blank. If you want you can make the button be pushed to the bottom by using layout_weight=1 on whichever view you want to take up the remaining space.

How can I change the layout of a dialogFragment when a softKeyboard is opened?

I've got a quite big dialogFragment, with 5 editText's, and some text, to explain what should be filled in. This dialogFragment fits on the screen perfectly fine, until the keyboard is opened. To compensate this, I would like to hide/remove the explanatory text while the keyboard is open.
The text is shown in a textView and in the dialog's message.
I know it's not simple to do something when the keyboard is opened/closed, but with some hacks, I hope it's doable.
So: How can I change the layout of the dialogFragment based on the state of the keyboard?
Click either image to view a bigger version
Also, as you can see in the second image, the clock / icons in the notification area (or whatever it's called these days) are showing through the dialogFragment. It would be lovely if that could be prevented too, for learning purposes, but that's not the most important part.

Android Gallery View showing two view on a single screen.

I'm designing a Gallery View in Android where I need to have two views occupying each half of the screen (2 views on a full screen). When the user scrolls it shows the next view. The Ideas behind this is to have five views and user see 2 views initially. I tried a couple options but without success,where setLayoutParams(new Gallery.LayoutParams(screenWidth/2, screenHeight/2)); didn't really solve the problem. If anybody encountered this kind if an issue send me an advice or path. Thank you for reading and please let me know if you need any further details in case if I didn't make my self clear.
two views occupying each half of the screen (2 views on a full screen)
to acheive this give both the views equal weight so that both takes equal height(half - half screen). then in the
setLayoutParams(new Gallery.LayoutParams(screenWidth/2, screenHeight/2));
instead of setting the screenwidth/2 and height/2 use fill parent there...
Hope it helps...
if found any issues with this... post your layout and code relevant to that...

Android: Creating a Scrollable Layout

I'm trying to create a "scrollable" layout in Android. Even using developers.android.com, though, I feel a little bit lost at the moment. I'm somewhat new to Java, but not so much that I feel I should be having these issues--being new to Android is the bigger problem right now.
The layout I'm trying to create should scroll in a sort of a "grid". I THINK what I'm looking for is the Gallery view, but I'm really lost as to how to implement it at the moment. I want it to "snap" to center the frame, like in the actual Gallery application.
Essentially, if I had a photo gallery of 9 pictures, the idea is to scroll between them up/down AND side to side, in a 3x3 manner. Doesn't need to dynamically adjust, or anything like that, I just want a grid I can scroll through.
I'm also not asking for anyone to give me explicit code for it--I'm trying to learn, more than anything. But pointing me in the right direction for helpful layout programming resources would be greatly appreciated, and confirming if it's a Gallery view I'm looking for would also be really helpful.
EDIT: To clarify, the goal is to have ONE item on screen at a time. If you scroll between one item and the next, the previous one leaves the screen, and the new one snaps into place. So if it were a photo gallery, each spot on the grid would take up the entire screen size, approximately, and would be flung out of the viewable area when you slide across to the next photo, in either direction. (Photos are just an example for illustration purposes)
This page gives a good summary of the different built in layout objects. From your description a GridView or possibly a TableLayout might work. GalleryView looks to be horizontal only.
I believe GridView is what you're looking for. Here's a tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html
You should check out the ViewPager widget, which is available in the Android compatibility package. I spent a loooong time trying to get the Gallery widget to behave properly, but finally settled on a ViewPager which returned ImageView objects instead. Works like a charm.

Categories

Resources