Search in sources :

Example 21 with ImageButton

use of android.widget.ImageButton in project Android-Iconics by mikepenz.

the class PlaygroundActivity method onCreate.

@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), new ForegroundColorSpan(Color.parseColor("#33000000")), new RelativeSizeSpan(2f)).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).color(Color.parseColor("#aaFF0000")).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, FontAwesome.Icon.faw_android).sizeDpX(48).sizeDpY(32).paddingDp(4).roundedCornersDp(8).color(Color.parseColor("#deFF0000")).toBitmap());
    //Show how to style the text of an existing button
    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();
    //Show how to style the text of an existing button
    ImageButton b6 = (ImageButton) findViewById(R.id.test6);
    StateListDrawable iconStateListDrawable = new StateListDrawable();
    iconStateListDrawable.addState(new int[] { android.R.attr.state_pressed }, new IconicsDrawable(this, FontAwesome.Icon.faw_thumbs_o_up).sizeDp(48).color(Color.parseColor("#aaFF0000")).contourWidthDp(1));
    iconStateListDrawable.addState(new int[] {}, new IconicsDrawable(this, FontAwesome.Icon.faw_thumbs_o_up).sizeDp(48).color(Color.parseColor("#aa00FF00")).contourWidthDp(2));
    b6.setImageDrawable(iconStateListDrawable);
    ListView listView = (ListView) findViewById(R.id.list);
    IconicsDrawable iconicsDrawableBase = new IconicsDrawable(this).actionBar().color(Color.GREEN).backgroundColor(Color.RED);
    IconicsDrawable[] array = new IconicsArrayBuilder(iconicsDrawableBase).add(FontAwesome.Icon.faw_android).add(Octicons.Icon.oct_octoface).add("Hallo").add('A').add(";)").build();
    listView.setAdapter(new IconsAdapter(this, array));
}
Also used : ForegroundColorSpan(android.text.style.ForegroundColorSpan) Iconics(com.mikepenz.iconics.Iconics) RelativeSizeSpan(android.text.style.RelativeSizeSpan) StateListDrawable(android.graphics.drawable.StateListDrawable) SpannableString(android.text.SpannableString) ImageButton(android.widget.ImageButton) ListView(android.widget.ListView) ImageButton(android.widget.ImageButton) Button(android.widget.Button) IconicsArrayBuilder(com.mikepenz.iconics.IconicsArrayBuilder) TextView(android.widget.TextView) ImageView(android.widget.ImageView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) BackgroundColorSpan(android.text.style.BackgroundColorSpan) ImageSpan(android.text.style.ImageSpan)

Example 22 with ImageButton

use of android.widget.ImageButton in project Knife by mthli.

the class MainActivity method setupStrikethrough.

private void setupStrikethrough() {
    ImageButton strikethrough = (ImageButton) findViewById(R.id.strikethrough);
    strikethrough.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            knife.strikethrough(!knife.contains(KnifeText.FORMAT_STRIKETHROUGH));
        }
    });
    strikethrough.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(MainActivity.this, R.string.toast_strikethrough, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) View(android.view.View)

Example 23 with ImageButton

use of android.widget.ImageButton in project Knife by mthli.

the class MainActivity method setupLink.

private void setupLink() {
    ImageButton link = (ImageButton) findViewById(R.id.link);
    link.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showLinkDialog();
        }
    });
    link.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(MainActivity.this, R.string.toast_insert_link, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) View(android.view.View)

Example 24 with ImageButton

use of android.widget.ImageButton in project Knife by mthli.

the class MainActivity method setupBullet.

private void setupBullet() {
    ImageButton bullet = (ImageButton) findViewById(R.id.bullet);
    bullet.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            knife.bullet(!knife.contains(KnifeText.FORMAT_BULLET));
        }
    });
    bullet.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(MainActivity.this, R.string.toast_bullet, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) View(android.view.View)

Example 25 with ImageButton

use of android.widget.ImageButton in project Knife by mthli.

the class MainActivity method setupItalic.

private void setupItalic() {
    ImageButton italic = (ImageButton) findViewById(R.id.italic);
    italic.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            knife.italic(!knife.contains(KnifeText.FORMAT_ITALIC));
        }
    });
    italic.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(MainActivity.this, R.string.toast_italic, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : ImageButton(android.widget.ImageButton) View(android.view.View)

Aggregations

ImageButton (android.widget.ImageButton)149 View (android.view.View)105 TextView (android.widget.TextView)83 ImageView (android.widget.ImageView)51 Button (android.widget.Button)26 ListView (android.widget.ListView)24 AdapterView (android.widget.AdapterView)23 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)19 Intent (android.content.Intent)18 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)11 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 MenuItem (android.view.MenuItem)7 Drawable (android.graphics.drawable.Drawable)6