|
1 | 1 | # CodeView |
2 | | - |
| 2 | +A code viewing library for displaying code in Android apps, built entirely in Kotlin. |
| 3 | + |
| 4 | +## Usage |
| 5 | +**Step 1.** Make sure `mavenCentral()` is added as a dependency in your root gradle file: |
| 6 | +```groovy |
| 7 | +allprojects { |
| 8 | + repositories { |
| 9 | + mavenCentral() |
| 10 | + } |
| 11 | +} |
| 12 | +``` |
| 13 | + |
| 14 | +**Step 2.** Add the dependency to your app's project gradle file: |
| 15 | +```groovy |
| 16 | +dependencies { |
| 17 | + implementation 'me.jackdevey:codeview:1.0.1' |
| 18 | +} |
| 19 | +``` |
| 20 | + |
| 21 | +**Step 3.** Add the CodeView to your layout |
| 22 | +```xml |
| 23 | +<me.jackdevey.codeview.CodeView |
| 24 | + android:id="@+id/code_view" |
| 25 | + android:layout_width="wrap_content" |
| 26 | + android:layout_height="wrap_content"/> |
| 27 | +``` |
| 28 | + |
| 29 | +**Step 4.** Customise the CodeView |
| 30 | +```kotlin |
| 31 | +binding.codeView.with{ |
| 32 | + fontSize = 14f |
| 33 | + code = "Code" |
| 34 | + show() |
| 35 | +} |
| 36 | + |
| 37 | +``` |
| 38 | + |
| 39 | +## Customisation |
| 40 | +You can customise the CodeView to make sure that it fits with the theme of your app using the variables below: |
| 41 | +> After any change is made, make sure that you use `show()` to re-draw the changes onto the view. |
| 42 | +
|
| 43 | +| Variable | Data type | Description | Default | Working | |
| 44 | +|----------|-----------|-------------|---------|--------| |
| 45 | +| code | String | The code to display on the view | "No code provided" | ✔ | |
| 46 | +| fontSize | Float | The font size of the text | 14f | ✔ | |
| 47 | +| numberLines | Boolean | Number each line | true | ❌ | |
| 48 | +| backgroundColour | Color | The colour of the background | GREY | ❌ | |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +## License |
| 53 | +This library is licensed under the [Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 54 | + |
| 55 | +See [`LICENSE`](LICENSE) for full of the license text. |
| 56 | + |
| 57 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 58 | + you may not use this file except in compliance with the License. |
| 59 | + You may obtain a copy of the License at |
| 60 | + |
| 61 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 62 | + |
| 63 | + Unless required by applicable law or agreed to in writing, software |
| 64 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 65 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 66 | + See the License for the specific language governing permissions and |
| 67 | + limitations under the License. |
0 commit comments