Hi,
I've read that you shouldn't put a ListView into a ScrollView, which makes sense.
What I want to do is put a ListView after/below a ScrollView.
Like this:
Code:
<LinearLayout>
<ScrollView />
<ListView />
</LinearLayout>
This works fine, untill what's inside the ScrollView (various TextViews) becomes so large that it needs scrolling.
In that case, the ScrollView only allows scrolling until the bottom of the ScrollView, and the ListView below is inaccessible.
Ok.
Use a RelativeLayout. Set the alignParentBotton="true" for the list and the layout_above="<LISTID>"
You will need to declare the listview above the ScrollView in the code. It will be shown below of it.
---------- Post added at 08:02 PM ---------- Previous post was at 08:00 PM ----------
Or do you want the scrolling to go on?
Use your own ListAdapter for that. For the first x rows set custom layouts and for everything below use another one.
A lighter solution is to use weights in linearlayout
Example: http://stackoverflow.com/questions/2698817/linear-layout-and-weight-in-android
Related
Hi,
I was just wondering, is there any way to have an animated widget on the android homescreen, which stays animated and consists of multiple frames? For instance, an animated flash, gif or png sequence?
Thanks
i never used animations on an app, but try it with gifs, or looped zip files, like bootanimation.zip, that creates an animated picture, from multiple files.
ilendemli said:
i never used animations on an app, but try it with gifs, or looped zip files, like bootanimation.zip, that creates an animated picture, from multiple files.
Click to expand...
Click to collapse
And this can be used as a simple widget?
don't know, wait for other posts, you can make a onclicklistener to an image
I'm not talking from experience here, but since widgets update in real time (facebook and twitter for example), there's obviously a method of updating what's displayed so I can't see any reason that you couldn't have an animated widget (other than the usual CPU and battery issues).
maybe develop a service that is constantly pushing messages to the widget? but I suppose this will be a huge battery drainer....
There should be a way to do it. After all, under the "res" folder, there is a supported and standard sub-directory called "anim" that can be used to bring compiled animation files to your app. Look into on the android developer site. I'm thinking this is the way to do it.
Here is a reference from the adroid dev site on using a class called AnimationDrawable:
public class
AnimationDrawable
extends DrawableContainer
implements Animatable Runnable
java.lang.Object
↳ android.graphics.drawable.Drawable
↳ android.graphics.drawable.DrawableContainer
↳ android.graphics.drawable.AnimationDrawable
Class Overview
An object used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
The simplest way to create a frame-by-frame animation is to define the animation in an XML file, placed in the res/drawable/ folder, and set it as the background to a View object. Then, call run() to start the animation.
An AnimationDrawable defined in XML consists of a single <animation-list> element, and a series of nested <item> tags. Each item defines a frame of the animation. See the example below.
spin_animation.xml file in res/drawable/ folder:
Code:
<!-- Animation frames are wheel0.png -- wheel5.png files inside the
res/drawable/ folder -->
<animation-list android:id="selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>
Here is the code to load and play this animation.
Code:
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start()
For more information, see the guide to Animation Resources.
demaxmeister said:
Hi,
I was just wondering, is there any way to have an animated widget on the android homescreen, which stays animated and consists of multiple frames? For instance, an animated flash, gif or png sequence?
Thanks
Click to expand...
Click to collapse
did you ever figure out a simple method to creating an animated simple widget? i was just wondering b/c this is something i too would like to have.
I found this on modaco a few days ago:
http://www.youtube.com/watch?v=G-4k62ln4j4
http://android.modaco.com/content/advent-vega-vega-modaco-com/329946/3d-desktop-plugin/#entry1567646
I think it is for a tablet? Is it possible to port?
Animation in widgets is possible, check my widget.
first off, yes animated widgets are possible. second, animated gifs are not supported natively by ImageView.
http://stackoverflow.com/questions/3660209/android-display-animated-gif
however agif is supported by the WebView so you could make a widget that is just a WebView that displays an animated gif.
http://stackoverflow.com/questions/2702860/how-to-make-animated-gifs-work-from-android-webview
it will suffer performance wise but it would work.
or you could just split the animated gif and make an AnimationDrawable
http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
cheers!
Please try Animated Photo Frame Widget
https://play.google.com/store/apps/details?id=com.hikaru.photowidgetad
Bump.
Year 2016, still can't figure out how to animated widget.
Can somebody help me please? I tried to google for it, but all i got was gif animation loops and animations in progress bar. I want to know how do people animate the widgets like that of MIUI, DU battery saver and other weather widgets. Is there a library to do it?
I'm totally lost right now after trying so many different ways to create a custom progress bar. I'm shooting for something like Catch Notes', it's a perfect example.
Right now, my Action Bar is calling a generic progress bar layout and that works fine. I've attached a picture of what I'm looking for to help even more.
Code:
switch (item.getItemId()) {
case R.id.refresh: //Obviously, this is my refresh Action Bar icon.
item.setActionView(R.layout.progress);
return true;
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
</LinearLayout>
http://developer.android.com/reference/android/widget/ProgressBar.html
one second...
i just noticed you are already setting your own style
Code:
style="?android:attr/progressBarStyleSmall"
can you post your progressBarStyleSmall.xml and other relevant drawables, layer-lists, shapes, and animations xml files?
i have been trying to make one of these for a while as well.
killersnowman said:
http://developer.android.com/reference/android/widget/ProgressBar.html
can you post your progressBarStyleSmall.xml and other relevant drawables, layer-lists, shapes, and animations xml files?
i have been trying to make one of these for a while as well.
Click to expand...
Click to collapse
The style I'm referencing is the default Android ProgressBar style for a small progress bar. You just drag the small progress bar into your layout.
k well you should look into making your own style. i have styles on the brain so i thought it was a custom one.
Im trying to create a simple app,which loads an image and displays it in an imageview and there is a scroll bar and button below.But after loading large images the image covers up the scroll bar and the button.Tried using different settings with each view's layout but nothing worked.What i want is the image should be displayed in the imageview placed at a fixed location the position of imageview should not be changed neither its size,im quite new to android development im looking for a property like strech in c# which stretches or reduces the size of the images so that it fits in the imageview
Can some one help me,posting the code from main.xml below
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="link"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView
android:id="@+id/imageView1"
android:layout_width="302dp"
android:layout_height="355dp"
android:src="@drawable/jellyfish" />
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="262dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:onClick="clickme"
/>
</LinearLayout>
ImageView has android:scaleType="some_scale_type" property, that does exactly what you require. You can stretch, keep original size or fill available area. There's a problem with you layout, though. Why do you use these absolute values? You know they will look ugly on devices with different DPI/screen sizes, not to mention orientation change?
I hope that I posted this thread correctly...
It's my first android app and I am using android studio. I want to get a screenshot of a specifi area.
My xml is in this format:
<LinearLayout>
<RelativeLayout>
<RelativeLayout>
<TextView />
<TextView/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
The two textviews are overlapping. The one holds an image (with transparency) and the other one, a background color and a text (this is why I have them on a single RelativeLayout and overlapping). I want to get a screenshot of this RelativeLayout. Any help please? Nothing of what I have used worked.
I'd like to make a few small changes in the framework-res.apk. I thought this might be "easy", but so far it's not.
I decompiled the apk file using apktool and located the two files I wanted to alter in res/layout. I made the changes, then saved the two edited files.
Next I opened the original framework-res.apk archive with WinRAR and then dragged the edited xml files into the proper location ("store", not "normal" or "compress") and then closed the archive.
Finally, I used CWM to copy the new framework-res.apk back to the NST and rebooted.
Boot loop.
Is it not possible to deal with slightly edited xml files in this way?
nmyshkin said:
I'd like to make a few small changes in the framework-res.apk. I thought this might be "easy", but so far it's not.
I decompiled the apk file using apktool and located the two files I wanted to alter in res/layout. I made the changes, then saved the two edited files.
Next I opened the original framework-res.apk archive with WinRAR and then dragged the edited xml files into the proper location ("store", not "normal" or "compress") and then closed the archive.
Finally, I used CWM to copy the new framework-res.apk back to the NST and rebooted.
Boot loop.
It is not possible to deal with slightly edited xml files in this way?
Click to expand...
Click to collapse
I found a working method: https://forum.xda-developers.com/t/...rk-res-apk-with-apktool.1545361/post-23589640
But...I want to move the quicknav bar to the top of the screen. The changes I made in the xml files do that, but the status bar covers the top part of the quicknav bar. Ideally I'd like the quicknav bar to cover the status bar (maybe not allowed?), or at least position right beneath it.
The relevant xml code which seems to control the screen position of the quicknav bar looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
<ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
<ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
<ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
<ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
I've changed "bottom" in lines 4 and 5 to "top". That gets the job done, but with the problem mentioned: the status bar covers the top portion of the quicknav bar.
Help?
Changing framework or services or whatever you don't need to go to recovery.
They are just part of Android and have no influence on the Linux.
Code:
# stop
<do stuff>
# start
How about a screen shot?
I don't even think that I've ever even seen the stock QuickNav.
I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
Renate said:
How about a screen shot?
I don't even think that I've ever even seen the stock QuickNav.
I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
Click to expand...
Click to collapse
Thanks for the response. I'll try the marginTop idea. I've been looking all over for something like that but just hadn't generated the proper search string I guess.
Getting screenshots was a lot harder than I anticipated. The quicknav bar seems to disable the side hardware buttons when it is displayed but I finally figured out a way to get reasonable shots. You can clearly see the issue with the status bar when the quicknav buttons are moved to the top.
nmyshkin said:
I finally figured out a way to get reasonable shots.
Click to expand...
Click to collapse
What's the matter? You don't like my AdbGrab.exe (in sig)?
Renate said:
I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
Click to expand...
Click to collapse
You were close (and right, of course)!
The bar becomes a little scrunched for some reason (less white space above and below icons/text) but it just abuts the status bar with android:layout marginTop="18dp". I don't care much about the loss of the white space, so it's on with the rest of my project.
Thanks again for the help.
Hmm, something's screwy.
Maybe try this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp">
<ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
<ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
<ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
<ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
<ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
</LinearLayout>
</FrameLayout>
Renate said:
Hmm, something's screwy.
Maybe try this:
Code:
<?xml version="1.0" encoding="utf-8"?>
...etc.
Click to expand...
Click to collapse
It seems to make no discernible difference. I notice that the line:
Code:
<HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
is missing from your version. That, too, seems to make no difference.
There is another xml file which seems to have something to do with the "appicons" (which are just png images stored in the apk, text included):
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/appIcon" android:layout_width="wrap_content" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:layout_gravity="top|left|center" android:id="@id/badgeImage" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>
Not seeing anything there that jumps out at me. If the android:layout_marginTop="18dp" is changed to something like "100dp" the bar more or less collapses into a fat line, as well as moving further down the display window, so there is some interaction between the "simple" shifting of the vertical display of the bar and the vertical size of the bar itself.
Like I say, it's not a big deal for me. As long as content is not cut off, a slight flattening of quicknav bar is fine.
All the tiles are 120 x 112 so that the horizontal scroll is overblown. (5 x 120 = 600).
I was trying to get rid of that.
Use my only Linear Layout and change layout_height="112dp"
For testing purposes you can also add android:background="#cccccc".
That way if the LL expands but the buttons don't you can see the shading.
Renate said:
All the tiles are 120 x 112 so that the horizontal scroll is overblown. (5 x 120 = 600).
I was trying to get rid of that.
Use my only Linear Layout and change layout_height="112dp"
For testing purposes you can also add android:background="#cccccc".
That way if the LL expands but the buttons don't you can see the shading.
Click to expand...
Click to collapse
Does the android:background="#cccccc" go in the LinearLayout section or in the overall FrameLayout? Right now it's kinda moot because I can't seem to produce an apk file that does not cause a bootloop. I have a previous trial version with android:layout_ marginTop="20dp" which does NOT produce a bootloop. The file size is about 2874 Kb. Every new version I try to build with Apktool today is coming out around 3366 Kb and they all cause a bootloop. I have no idea what is going on with Apktool, but I'll keep plugging away, with breaks for mental health!
nmyshkin said:
Does the android:background="#cccccc" go in the LinearLayout section...
Click to expand...
Click to collapse
In the LL.
When you're floundering in layouts, it's helpful to set some color background for each containing element.
Obviously, on a B&W device you'll not see that, but a screen grab will show it.
(You can just stick to background colors that are differentiable in B&W,)
The FrameLayout is the whole screen which dims the normal screen.
The LinearLayout should be 600 x 120 automatically.
You can even do a reality check by saying (in LL) android:layout_height="500dp".
Renate said:
When you're floundering in layout...
Click to expand...
Click to collapse
I think "floundering" is the operative word here!
Try as I might, I have been unable to produce a framework-res.apk that did not cause a boot loop IF I left out the
Code:
<HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
This is what I have right now:
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<HorizontalScrollView android:layout_gravity="top|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:layout_gravity="top|center" android:layout_width="wrap_content" android:layout_height="112dp" android:layout_marginTop="18dp" android:background="#cccccc">
<ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
<ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
<ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
<ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
<ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
I was surprised to find that changing android:layout_gravity="top|center" in the LinearLayout section did NOT move the bar to the top. It was only when I made the change in the HorizontalScrollView that the bar went to the top of the screen (or almost).
I don't see any shading and perhaps the boxes are now even a bit smaller than before (see screenshot below). Again, I could live with this so it's not a deal-breaker for my intended project. It is interesting (and maybe just a little hair-raising) how these things interact in ways that I would not expect.
When you have a "boot loop" (which is just really Android flailing while the Linux is fine) you should check the logcat, it will tell you where the problem is.
I don't know how I missed where that HorizontalScroll was being used.
Yeah, I do. I was accidentally looking for quickNavHsView and not quickNavHSView.
In services.jar, com/android/server/status/StatusBarService uses that.
It must be a HorizontalScroll. You need that.
The quick nav itself is com/android/server/status/BNGossamerQuickNavbar
The default for layouts is top anyway.
Make the LinearLayout big, android:layout_height="300dp".
You won't see any background of the LL until it's bigger than its contents.
Renate said:
Make the LinearLayout big, android:layout_height="300dp".
You won't see any background of the LL until it's bigger than its contents.
Click to expand...
Click to collapse
OK. I did that but I'm not sure exactly what it tells me except that the size of the layout is greater than the size of the actual navbar images? I see this sort of thing when I am designing a scene in Tasker and the background field is larger than the image itself. There I would know what to do. Here....
Also, how does this relate to the squished (cut off?) images in the navbar?
Edit: I take some of this back now that I have looked more closely at the screenshot. The navbar is not so squished, although still not full size. This would suggest that if I make android:layout_height even larger the navbar will return to normal size. And maybe it does not matter since the background is transparent if I don't specify a color?
So, Bob's your uncle.
For the LinearLayout
android:layout_height="152dp" android:layout_marginTop="40dp"
You don't need to add a background.
How are you getting those screenshots and why are they JPEGs?
You can use
Code:
# screenshot /sdcard/snap.png
I forget if AdbGrab works for that.
There is that whole screenshot/screencap/framebuffer thing.
(Also format 1 & formt 2)
Renate said:
So, Bob's your uncle.
For the LinearLayout
android:layout_height="152dp" android:layout_marginTop="40dp"
You don't need to add a background.
How are you getting those screenshots and why are they JPEGs?
You can use
Code:
# screenshot /sdcard/snap.png
I forget if AdbGrab works for that.
There is that whole screenshot/screencap/framebuffer thing.
(Also format 1 & formt 2)
Click to expand...
Click to collapse
Well, that's just nifty! Thanks for looking at this and helping out.
I'm getting the screenshots using my swiss army knife app QuickTiles which includes a screenshot option. This uses the Screenshot Easy app as a plugin. I selected jpeg as the format, could have been png. You may recall that the native screenshot capabilities of the NST leave something to be desired. Screenshots come out with a green cast (or is is blue?) because of some weird color coding which I can't remember now.
Anyway, I normally have Quick Tiles assigned to the "clock" region of the status bar, but I want the quicknav bar there, so I temporarily assigned Quick Tiles to the "n" button. As much as I love Quick Tiles and spent a lot of time figuring it all out, I will be the first to admit that it is sometimes maddeningly slow to open. Other times it is nearly immediate, just like any other app on the NST. The quicknav bar (which I don't use at all), opens instantaneously. Over time and use I've worked my tile selection down to 5 (6 for my NSTG), so I've been thinking about trying to adapt the quicknav bar to replace Quick Tiles. It doesn't have the gee-whiz stuff like the battery percentage, date, and so on, but the response time is what I'm after at this point in my life.