i'm facing a problem that i never came accross before:
well i successfully applyed the 3D transition between a listview and someother layout container some info about the selected item. well the probelm is: some of the textviews are displayed correctly while others display nothing, even the imageview is shown as expected...
any suggestions?
thanks in advance..
I guess you had same collision in android:name tags. Acting wierd could happen by many reasons, but one of the most liklly to happen is when you have some collision in names, I mean more views defined with same name
#+id/something definition and #id/something reference is okey
but having #+id/something twice sometimes could be a problem.
This kind of references is usually used in relative layaout when you say I want this view to be to the left (or above, or below) some other view. Then you must give a reference to other view...
I fixed this: well i don't know the exact reason but it solved the problem
i changed the textview id in the layout and it worked fine. Weird why it didn't work until this..if any one can explain it would be great^^
I have 2 text view with the same id, one of them is inside the parent layout and the other one was in the viewpager which is child of the parent layout. I changed the latter one is and the problem is solved.
Related
I currently have two RelataiveLayouts in my android prototype.
I created a title id in the first layout by calling:
android:id = "#+id/title"
From another layout, I wanted to place an ImageView below the title, so I called in another layout,
android:layout_below = "#id/title"
There is no error occurring but I am not seeing it working.
Please advise me!
Thanks in advance :)
UPDATE: September 21st 2014
Okay I think I found what is wrong on the layout structure.
I use 1 actionbar layout to contain fragment layouts. But what I think is that, the layout
is more like overlayed not actually nested within the actionbar layout. That seems like why
"android:layout_below" did not work eventhough I do not get compilation/build error.
So the structure is like this:
So the title is positioned at the same place for all different tabs,
and I want to place images or text below that #id/title in the actionbar layout.
Please advise once again ! ;)
I'm currently using a Viewpager with 3 fragment. I would like to know if I can change the width of the first fragment.
In fact , I try this do to something like the category menu in the android play store when you watching it with tablet, it looks like a fragment but its not taking all the space when swiping to it so you still see the fragment next to it (i don't know if i'm clear). I was wondering if I could simply do that by changing the width of the first fragment from MATCH_PARENT to a fixed value, i don't even know if the result of this could be nice.
i tried setLayoutParams() , set it in the xml , nothing seems to work. the fragment still match parent.
With ViewPager, it is not supported. You have to write your own ViewGroup class, or you might try something as i answered in this question.
Actually, you might want to try setting a negative margin on the pages in the ViewPager, using setPageMargin(int). See also this answer I provided not too long ago on a similar question:
Can I set viewpager's item width?
I am having weird scrolling issues in my pretty simple GridView. Each item in the Grid is simply an ImageView and a TextView. The activity itself is simply an application selector. It looks like a rough version of the basic App Tray in Android.
The issue is that after spending some times scrolling through my view, it will inevitably allow me to continue scrolling past the top row of icons, to a blank screen, and the scroll bar will disappear, leaving me stuck.
It doesn't happen every time I go to the top of the view, only sometimes, and usually only after some excessive scrolling.
If I happen to notice the problem and catch it before the top row disappears off the bottom of the screen, I can usually scroll back through the view and spot some icons missing. There are empty spaces in the grid, and I can only assume that those icons have been moved to some bizarre position, which is allowing the view to scroll past the top.
This is my first Android app beyond a basic Hello World, so it's likely that I've just screwed up something in my layout files. I also realize that this is probably a pretty confusing description, so I'm hoping someone has experienced this and my search abilities simply were unable to find it.
I can post my layout files or other code if someone thinks that's useful.
Oh, and the program is built against 1.5, but is running on 2.2 (whatever state of 2.2 that was that snuck out last week) on my phone. I don't have enough apps to test this on an emulator, but could probably set something up if someone felt it necessary.
Thanks in advance for any help on the issue.
I had same problem, but I post to GridView only ImageView's so pengwang's answer didn't help me. I found explanation for this bug https://code.google.com/p/android/issues/detail?id=16218
The problem is that GridView does not currently handle items with differing heights.
My solution is to use exactly specified layout_height same for all GridView's items.
i have solved it: in the link GridView cannot show image you can try
It seems that if you scroll off the bottom of the GridView and back again very fast a couple of times, you eventually will notice that the elements of the view get shifted one place to the "left" from where they originally were. When this happens, you then can scroll all the way off the top of the GridView. When you do reach the top of the list, item 0 is not displayed, having item 1 in its place and nothing but blackness above that row.
Clicking on any item in this situation resets the list and everything is back to normal.
This must be a bug. It's highly reproducible, and I don't think anything I'm doing is causing the mix up. At this point, adding to the list adapter has stopped.
Right now I'm working with Android 2.3.3.
I just ran into this exact same issue myself -- I have a grid of images that have different heights. After reading the Android developer's doc on GridView, GridView.LayoutParams and GridLayout, I did two things that fix my issue:
find the tallest image in each row, and store the height in a map of row -> rowHeight. Each image that I download has width and height info, so this is easy for me to do by overriding my adapter's addAll(items) method.
in getView(), I create a GridView.LayoutParams(MATCH_PARENT, getRowHeight(position)), which sets each grid item to the max row height for its specific row.
wrap my ImageView inside a LinearLayout. I have tried other layout but LinearLayout is the one that works. Set android:scaleType="fitCenter" and android:adjustViewBounds="true" for the image view.
After above 3 steps I finally got the grid to look right, they have different heights, and there's no scrolling issues.
I had a similar, but probably less common problem, where just scrolling a little bit would scroll the gridview to the end and I was not able to scroll up at all. This only occurred when the gridview was smaller, for example when the keyboard was visible. The problem was that I used:
android:paddingBottom="400dp"
android:clipToPadding="false"
Making padding bottom much smaller fixed my issue. I hope this helps at least someone!
My layout contains a ListView (the parent is a LinearLayout). I have defined a certain drawable to be the ListView's background.
When I press an empty space below the last row, all the list rows turn black.
I'd like to attach screenshots but for some reason it adding images here doesn't work for me...
Can someone explain how to attach screenshot?
Any idea why this happens? Couldn't catch any click event in this activity...
Thanks, Rob
Not sure if this is what's causing your problem, but have you read this post? http://developer.android.com/resources/articles/listview-backgrounds.html
I think I once experienced this problem a while ago.
I think it might be something to do with the following two tags in the listview's layout xml file.
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"
I rekon they're probably set to different colours in your file? (or missing). Try making them the same colour and see if it still does it. Plus, I rekon that if you had enough rows that the list view overflowed the screen, it would go black like you describe when you scrolled.
This is a bit of a long-shot, but I hope it helps.
Got a little problem with a functionality I'd like to implement.
I've got a LinearLayout, containing 2 TextViews. I'd want to set a onClickListener on it, so that it would behave just like an item in a ListView.
I've tried some possible implementation of this, and got it working using the xml attribute android:onClick of the LinearLayout.
As I want the application to visually react to a click on the LinearLayout (as in a ListView), I put this in the listener callback method :
l.setBackgroundColor(android.R.drawable.list_selector_background);
l is a LinearLayout object, initialised with findViewById();
I get an application not responding whenever I try to click on the layout. I tried to replace the code in the callback method by a Toast message show up, and it works, so I guess the problem is in the setBackgroundColor.
Is anyone familiar with this?
PS: sorry, I can't post more code right now, I'm at work.
You have to set LinearLayout attribute android:clickable="true" in the xml layout file or setClickable(true) in the java activity code.
i noticed that all the advices above don't helpt as long as any of the child elements inside the LinearLayout has the attribute android:textIsSelectable="true".
I found that that setClickable(true) would still cause clicks to go to children of the linearlayout. I found that to have the LinearLayout capture the touch instead of it's children I had to override the dispatchTouchEvent method so I created a subclass of LinearLayout for just this purpose. Seems like an ugly solution though.
you should set the LinearLayout's focusable to true and set all the children view's focusable to false, don't use the android:clickable="true", but you can't see the effect of the click of the linelayout. BTW, the best way is to implement the onTouchEvent api.
android:clickable="true" works perfectly under one condition.
Youhave to put the childs inside the LilnearLayout to android:clickable="false".
Had the same problem, I've been trying for an hour all the answers in SO but none worked.
Then I realized I just had to promote my LinearLayout to the bottom of the layout, since other views blocked it, and then it worked, without adding ANY special attributes to the layout.
Putting it here in case it might help someone someday.