'android'에 해당되는 글 78건

  1. 2014.06.26 Android: Use a custom font everywhere
  2. 2014.06.26 HzGrapher
  3. 2014.06.26 Pull To Refresh
  4. 2014.06.26 View Badger
  5. 2014.06.26 IndexableListView
  6. 2014.06.26 Android Coverflow
  7. 2014.06.26 Wheel Widget
  8. 2014.06.26 AndroidDrawer
  9. 2014.06.26 Radial Menu Widget
  10. 2014.06.26 Swipe-To-Dismiss
android2014.06.26 13:42

The View Crawler

Layouts (and sub-layouts) in Android are tree hierarchies comprised of ViewGroups as composite elements and Views as leaf nodes. This tree can be crawled by visiting child views in your favorite order (breadth first or depth first). When crawling this tree, one can replace all the Typefaces on any TextViews, EditTexts, and Buttons that are encountered.

Here is a simple recursive implementation of a view crawler that will replace theTypeface for any appropriate view in the hierarchy:

public class FontChangeCrawler
{
    private Typeface typeface;

    public FontChangeCrawler(Typeface typeface)
    {
        this.typeface = typeface;
    }

    public FontChangeCrawler(AssetManager assets, String assetsFontFileName)
    {
        typeface = Typeface.createFromAsset(assets, assetsFontFileName);
    }

    public void replaceFonts(ViewGroup viewTree)
    {
        View child;
        for(int i = 0; i < viewTree.getChildCount(); ++i)
        {
            child = viewTree.getChildAt(i);
            if(child instanceof ViewGroup)
            {
                // recursive call
                replaceFonts((ViewGroup)child);
            }
            else if(child instanceof TextView)
            {
                // base case
                ((TextView) child).setTypeface(typeface);
            }
        }
    }
}

Replace Entire Activity's Typeface

To replace the default font in every view within an Activity's layout, simply use theFontChangeCrawler from above, like so:

@Override
public void setContentView(View view)
{
    super.setContentView(view);

    FontChangeCrawler fontChanger = new FontChangeCrawler(getAssets(), "font.otf");
    fontChanger.replaceFonts((ViewGroup)this.findViewById(android.R.id.content));
}

If you are not familiar with android.R.id.content, it is the official ID given to the rootView within an Activity's layout.

Consider placing the above logic in a BaseActivity class.

Replace Fragment's Typeface

You will need to apply the FontChangeCrawler to each Fragment as well. Consider placing this logic in a BaseFragment class.

@Override
public void onActivityCreated(Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    FontChangeCrawler fontChanger = new FontChangeCrawler(getAssets(), "font.otf");
    fontChanger.replaceFonts((ViewGroup) this.getView());
}

Handle Adapters, etc.

Replacing Activity fonts goes a long way, but most of us also have a plethora ofListViews. The list items in a ListView are built within an adapter, not within an Activity. Therefore, you will also need to use the FontChangeCrawler in your adapters:

...
if(convertView == null)
{
    convertView = inflater.inflate(R.layout.listitem, null);
    fontChanger.replaceFonts((ViewGroup)convertView);
}
...

What's Not Handled?

I will leave handling the ActionBar as an exercise for the reader. Also, consider how you might handle widgets whose typeface you don't want to change.

신고
Posted by 레드오이
android2014.06.26 11:24

HzGrapher

android hz graph library

Function

  • Line Graph Screenshot

  • Line Graph with Region Screenshot


https://github.com/handstudio/HzGrapher

신고
Posted by 레드오이
android2014.06.26 10:56
25 October
8

Pull To Refresh

By Chris Banes

This project aims to provide a reusable Pull to Refresh widget for Android. It was originally based on Johan Nilsson’s library (mainly for graphics, strings and animations), but these have been replaced since.

Features

  • Supports both Pulling Down from the top, and Pulling Up from the bottom (or even both).
  • Animated Scrolling for all devices.
  • Over Scroll supports for devices on Android v2.3+.
  • Currently works with ListViewExpandableListView & GridViewWebView and ScrollView!
  • Integrated End of List Listener for use of detecting when the user has scrolled to the bottom.
  • Maven Support.
  • Indicators to show the user when a Pull-to-Refresh is available.
  • Support for ListFragment!
  • Lots of Customisation options!

https://github.com/chrisbanes/Android-PullToRefresh

신고
Posted by 레드오이
android2014.06.26 10:55

View Badger

By Jeff Gilfelt

A simple way to “badge” any given Android view at runtime without having to cater for it in layout.

Download: GitHub

https://github.com/jgilfelt/android-viewbadger

신고
Posted by 레드오이
android2014.06.26 10:55
23 October
3

IndexableListView

By Daniel Nam

iPhone like fast scroll ListView on Android.

https://github.com/woozzu/IndexableListView

신고
Posted by 레드오이
android2014.06.26 10:54

Android Coverflow

A simple implementation of coverflow for Android. It is largely based on code example written byNeil Davies.

The Coverflow view works pretty much like the standard Android Gallery widget, but with the addition of the rotation of the images.

https://code.google.com/p/android-coverflow/

신고
Posted by 레드오이
android2014.06.26 10:54

Wheel Widget

The Wheel Widget by Yuri Kanivets is supposed to serve as Android’s equivalent to the iOS’UIPickerView.

The library features a few examples, such as Country/City selection, Date and Time selection.

Download: Google Code

https://code.google.com/p/android-wheel/

신고
Posted by 레드오이
android2014.06.26 10:53

AndroidDrawer

By Łukasz Milewski

A simple but powerful menu drawer implementation. A lot of functionally are based on very good article by Cyril Mottier and Facebook mobile application.

You don’t need to extend yet another Activity implementation, this simplify integration with bigger applications.

https://bitbucket.org/verdigo/drawer/

신고
Posted by 레드오이
android2014.06.26 10:52

Radial Menu Widget

By Arindam Nath

A radial menu widget released in this tumblr post.

https://code.google.com/p/radial-menu-widget/

신고
Posted by 레드오이
android2014.06.26 10:52

Swipe-To-Dismiss

by .

This is Android 4.0 style Swipe-To-Dismiss implementation.
The implementation works on vertical LinearLayouts and ListViews as well, and should imitate the behaviour of Android 4.0+ app switcher.

Download: GitHub

https://gist.github.com/romannurik/2980593

신고
Posted by 레드오이

티스토리 툴바