项目作者: zeoflow

项目描述 :
An Android markdown library - it does not require WebView
高级语言: Java
项目地址: git://github.com/zeoflow/stylar.git
创建时间: 2020-10-03T04:56:11Z
项目社区:https://github.com/zeoflow/stylar

开源协议:Apache License 2.0

下载


Stylar for Android (Deprecated)

Intro

An Android markdown library - it does not require WebView

Getting Started

For information on how to get started with Stylar,
take a look at our Getting Started guide.

Submitting Bugs or Feature Requests

Bugs or feature requests should be submitted at our GitHub Issues section.

How does it work?

1. Depend on our library

Stylar for Android is available through Google’s Maven Repository.
To use it:

  1. Open the build.gradle file for your application.
  2. Make sure that the repositories section includes Google’s Maven Repository
    google(). For example:

    1. allprojects {
    2. repositories {
    3. google()
    4. jcenter()
    5. }
    6. }
  3. Add the library to the dependencies section:

    1. dependencies {
    2. // ...
    3. implementation 'com.zeoflow:stylar:<version>'
    4. // ...
    5. }

2. Add the StylarView component to your app

activity_main.xml

  1. <!--
  2. ...
  3. -->
  4. <com.zeoflow.stylar.view.StylarView
  5. android:id="@+id/zStylarView"
  6. android:layout_width="match_parent"
  7. android:layout_height="wrap_content"></com.zeoflow.stylar.view.StylarView>
  8. <!--
  9. ...
  10. -->

3. Activity/Fragment Class

MainActivity.java

  1. public class MainActivity extends BindAppActivity<ActivityMainBinding, MainViewBinding>
  2. {
  3. //..
  4. private StylarView zStylarView;
  5. //..
  6. @Override
  7. protected void onCreate(@Nullable Bundle savedInstanceState)
  8. {
  9. //..
  10. zStylarView = findViewById(R.id.zStylarView)
  11. //..
  12. final Stylar stylar = Stylar.builder(this)
  13. .withLayoutElement(zStylarView)
  14. .withAnchoredHeadings(true)
  15. .withImagePlugins(true)
  16. .withCodeStyle(false)
  17. .setClickEvent(link -> Toast.makeText(MainActivity.this, link, Toast.LENGTH_SHORT).show())
  18. .usePlugin(new AbstractStylarPlugin() {
  19. @Override
  20. public void configureTheme(@NonNull StylarTheme.Builder builder) {
  21. builder
  22. .codeTextColor(Color.parseColor("#CE570CC1"))
  23. .codeBackgroundColor(Color.parseColor("#EDEDED"));
  24. }
  25. })
  26. .build();
  27. //..
  28. String mdText = "**[test](#test)**";
  29. stylar.setMarkdown(mdText);
  30. //..
  31. }
  32. //..
  33. }

License

  1. Copyright 2020 ZeoFlow
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.

🏆 Contributors 🏆