陈斌彬的技术博客

Stay foolish,stay hungry

Android-iconify使用说明

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons

github地址:https://github.com/cnbin/android-iconify

效果

img

build.gradle(Module:app)中添加

dependencies {

    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' // (v4.5)
    compile 'com.joanzapata.iconify:android-iconify-entypo:2.2.2' // (v3,2015)
    compile 'com.joanzapata.iconify:android-iconify-typicons:2.2.2' // (v2.0.7)
    compile 'com.joanzapata.iconify:android-iconify-material:2.2.2' // (v2.0.0)
    compile 'com.joanzapata.iconify:android-iconify-material-community:2.2.2' // (v1.4.57)
    compile 'com.joanzapata.iconify:android-iconify-meteocons:2.2.2' // (latest)
    compile 'com.joanzapata.iconify:android-iconify-weathericons:2.2.2' // (v2.0)
    compile 'com.joanzapata.iconify:android-iconify-simplelineicons:2.2.2' // (v1.0.0)
    compile 'com.joanzapata.iconify:android-iconify-ionicons:2.2.2' // (v2.0.1)
}

img

activity_main.xml添加

  <com.joanzapata.iconify.widget.IconTextView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/icon"
        android:textSize="25sp"
        android:textColor="@color/colorAccent"
        android:minWidth="35dp"
        android:gravity="center"/>

img

MainActivity.java添加

public class MainActivity extends AppCompatActivity {

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

        Iconify
                .with(new FontAwesomeModule())
                .with(new EntypoModule())
                .with(new TypiconsModule())
                .with(new MaterialModule())
                .with(new MaterialCommunityModule())
                .with(new MeteoconsModule())
                .with(new WeathericonsModule())
                .with(new SimpleLineIconsModule())
                .with(new IoniconsModule());

        IconTextView iconTextView = (IconTextView)findViewById(R.id.icon);
        iconTextView.setText("I {fa-heart-o} to {fa-code} on {fa-android}");
    }
}

img