ThatCakeID / os-thm-android

Open Source Global Theme Manager for Android
https://os-thm.thatcakeid.com
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Custom Widgets #44

Open iyxan23 opened 3 years ago

iyxan23 commented 3 years ago

Custom Widgets, like qt and gtk. Basically, you can change how widgets (button, imageview, textview, slider, etc) are drawn on the screen by applying a theme.

Not only that, we can also add custom attributes to the custom widgets, making it very easy for the developer to set color for widgets in the xml code without messing around with the java code (except for the getCurrentTheme() function, we still need that).

Example (note that this example code is for demonstration purposes, it is not the final version):

A piece of the XML Layout code:

<tw.osthm.widgets.Button
      android:id="@+id/myButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="18dp"
      android:text="button"

      osthm:foregroundColor="colorAccent"
      osthm:textColor="colorBackgroundText"
      osthm:shadowColor="colorShadow"
      osthm:isShadowEnabled="true/false/default (theme dependant)"

      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" />

Java code:

OsThmTheme currentTheme = osthmEngine.getCurrentTheme();
osthmLayout layout = new osthmLayout(MainActivity.this);

layout.apply(currentTheme);
ToastcodeDev commented 3 years ago

300px-Android_Oreo_8.1_logo.svg.png