Android Open Source - Android-Iconics Playground Activity






From Project

Back to project page Android-Iconics.

License

The source code is released under:

Apache License

If you think the Android project Android-Iconics listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2014 Mike Penz/*ww  w  . j  a v  a  2  s .  c  o  m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.mikepenz.iconics.sample;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.text.style.DynamicDrawableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.RelativeSizeSpan;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.mikepenz.iconics.Iconics;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.FontAwesome;


public class PlaygroundActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_playground);

        //Show how to style the text of an existing TextView
        TextView tv1 = (TextView) findViewById(R.id.test1);
        new Iconics.IconicsBuilder().ctx(this)
                .style(new ForegroundColorSpan(Color.WHITE), new BackgroundColorSpan(Color.BLACK), new RelativeSizeSpan(2f))
                .styleFor("faw-adjust", new BackgroundColorSpan(Color.RED))
                .on(tv1)
                .build();

        //You can also do some advanced stuff like setting an image within a text
        TextView tv2 = (TextView) findViewById(R.id.test5);
        SpannableString sb = new SpannableString(tv2.getText());
        IconicsDrawable d = new IconicsDrawable(this, FontAwesome.Icon.faw_android).sizeDp(48).paddingDp(4);
        sb.setSpan(new ImageSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv2.setText(sb);


        //Set the icon of an ImageView (or something else) as drawable
        ImageView iv2 = (ImageView) findViewById(R.id.test2);
        iv2.setImageDrawable(new IconicsDrawable(this, FontAwesome.Icon.faw_thumbs_o_up).sizeDp(48).contourColor(Color.RED).contourWidthDp(1));

        //Set the icon of an ImageView (or something else) as bitmap
        ImageView iv3 = (ImageView) findViewById(R.id.test3);
        iv3.setImageBitmap(new IconicsDrawable(this, new FontAwesome(), FontAwesome.Icon.faw_android).color(Color.GREEN).toBitmap());

        //Show how to style the text of an existing button (NOT WORKING AT THE MOMENT)
        Button b4 = (Button) findViewById(R.id.test4);
        new Iconics.IconicsBuilder().ctx(this)
                .style(new BackgroundColorSpan(Color.BLACK))
                .style(new RelativeSizeSpan(2f))
                .style(new ForegroundColorSpan(Color.WHITE))
                .on(b4)
                .build();
    }
}




Java Source Code List

android.view.IconicsButton.java
android.view.IconicsTextView.java
com.mikepenz.google_material_typeface_library.GoogleMaterial.java
com.mikepenz.iconics.IconicsDrawableOld.java
com.mikepenz.iconics.IconicsDrawable.java
com.mikepenz.iconics.Iconics.java
com.mikepenz.iconics.sample.CustomApplication.java
com.mikepenz.iconics.sample.MainActivity.java
com.mikepenz.iconics.sample.PlaygroundActivity.java
com.mikepenz.iconics.sample.adapter.IconAdapter.java
com.mikepenz.iconics.sample.typeface.CustomFont.java
com.mikepenz.iconics.typeface.FontAwesome.java
com.mikepenz.iconics.typeface.IIcon.java
com.mikepenz.iconics.typeface.ITypeface.java
com.mikepenz.iconics.utils.IconicsTypefaceSpan.java
com.mikepenz.iconics.utils.Utils.java
com.mikepenz.meteocons_typeface_library.Meteoconcs.java