How to Make a Draggable Music Knob in Jetpack Compose - Android Studio Tutorial

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии • 54

  • @codinginflow
    @codinginflow 3 года назад +35

    nice knob bro

  • @harshrastogi1996
    @harshrastogi1996 10 месяцев назад +2

    your videos helps me a lot whenever people ask me the resources to learn Android advice them to learn from the GOAT . U explain things very nicely sir ,really admire you a lot .This video was really amazing learned a lot from your videos LOVE FROM INDIA

  • @mehulbisht9708
    @mehulbisht9708 3 года назад +8

    When you posted that video that declared the end of the ongoing Web dev series on your channel, I really felt confused with your decision after that video, but the very next video you uploaded after that, I still remember the smile that you had when you started the series on Jetpack Compose. Compose is like irresistible for Philipp! Cheers! keep composing happily :)

  • @Ayor88
    @Ayor88 9 месяцев назад +2

    your videos are gold for self learner !

  • @johanneshuotari
    @johanneshuotari 3 года назад +2

    The angle calculation solved my games ridiculous bug! Random dynamite got me this time, thanks.

  • @Javier_Chang
    @Javier_Chang 3 года назад +1

    I had checked your code, and thank you for your kindness to add knob photo on the source code, it allows me to create it easily.

  • @titkot96
    @titkot96 3 года назад

    You are making the best modern Android among YT, thank you so much!

  • @sokrates297
    @sokrates297 3 года назад +1

    Been waiting to make one of these for a long time!

  • @tonnie7079
    @tonnie7079 2 года назад

    Thanks for reminding me about the dreaded Trig fxns, they are not dreaded after all when you use them practically like in this knob.

  • @SahilGargjava
    @SahilGargjava 3 года назад +5

    Just a suggestion,
    if you could try creating the custom composable element first then show all the custom parameters that can be passed into it. By this way I think we can understand better like okay this is why we are adding this parameter. Now what happens is I wouldn't be able to relate to the parameter usage in the beginning itself.
    Anyhow, great tutorials ❤️

  • @valtteri_its_james
    @valtteri_its_james Год назад +1

    Mate, you are LEGEND!!!

  • @Blackops1990
    @Blackops1990 Год назад

    ThxWorks 100% just small changes starting @9:26 you'll get some red for Int convert and some Doubles + Float Converts. other then at all good

  • @halvtysk
    @halvtysk 2 года назад +1

    Great example that covers a practical use of compose. However, my OCD doesn't like that when you turn the knob all the way to the bottom, there is still one bar that is green... :P

    • @rollebonmarquis7574
      @rollebonmarquis7574 Год назад

      I suppose, one more problem for your OCD: similar thing happens when you turn the knob to the half. there would be 11 active bars instead of 10, etc.
      The solution imho is simple though: color = if (index < numberActiveBars) barColor else Color.DarkGray. "< than" instead of in range.

  • @Kunal-jp8tn
    @Kunal-jp8tn 3 года назад

    Thank you so much for this video. Would really appreciate if you make another tutorials for the 'Side Effects & Effect Handlers'.
    It would be really helpful.

  • @Chintanparmar
    @Chintanparmar 3 года назад

    Commenting for better reach!

  • @mohamedzahar7877
    @mohamedzahar7877 2 месяца назад

    That was impressive 👏👏👏

  • @safsfsfdfgdg
    @safsfsfdfgdg 2 года назад +3

    The atan2 function takes Y coord first and in the code we took X coord first. I suspect that is the reason you had to negate the value. Also, I am curious why we did not add left coordinate to width/2 to compute centerX and likewise top coordinate to height / 2 to compute centerY?

    • @rollebonmarquis7574
      @rollebonmarquis7574 Год назад

      In regards to the second part, I think he doesn't add the left and the top coordinate to compute the center because the touch coordinate that we get from the "modifier.pointerInteropFilter {...}" seems to be in respect to the view itself as opposed to anything else (window/parent/etc.). At least that's the impression that I got, and, if that's the case, then size/2 is all that we need for the center (no need for offseting it).

  • @abdullahalqahtani3841
    @abdullahalqahtani3841 3 года назад +2

    Good work 👏. Can we have a tut on how to use google maps with jetpack compose?

  • @prateekkumar151
    @prateekkumar151 3 года назад +3

    Why he had to multiply by -1 to get the correct result?
    The correct explanation (might be wrong):-
    In normal trigonometry, we calculate the angle from the horizontal axis, but in android, the angle is calculated from the vertical axis.
    tan(@) = Base/Height
    What he assumed to be base was actually height in android.
    Also, in the android coordinate system, the top left corner is (0,0)
    So the correct way to calculate tan will be(assuming we are starting our calculation from 1st quadrant):-
    val height =touchX - centerX
    val base = centerY - touchY
    val radianAngle = atan2(height,base)
    val degreeAngle = radianAngle * (180f / PI).toFloat()

  • @tanjimahmed213
    @tanjimahmed213 3 года назад

    Thanks for your amazeing video

  • @hellosagar
    @hellosagar 3 года назад

    Great explanation

  • @rollebonmarquis7574
    @rollebonmarquis7574 Год назад

    If you don't want to use the minus sign in front of the angle, I think this should be working too:
    touchX = event.x
    touchY = event.y
    val angle = atan2(-(centerX - touchX), centerY - touchY) * (180f / PI).toFloat()
    That's also my answer as to why we need the minus. I don't think it has to do anything with the fact that the first param in kotlin function is y instead of x... Inho it has to do more with how we calculate dy in this case for example (the param that we pass to atan2).
    Here's one more calculation that seems to be working for me:
    val opposite: Float = touchX - centerX
    val adjacent: Float = (touchY - centerY)
    val angleRadians: Float = atan2(y = opposite, x = -adjacent)
    val angleDegrees: Float = (angleRadians * 180 / Math.PI).toFloat()

    • @harishgaming2274
      @harishgaming2274 10 месяцев назад

      Could you xplain y there is a - here?

    • @rollebonmarquis7574
      @rollebonmarquis7574 10 месяцев назад

      ​@@harishgaming2274 probably, both the minus here and the minus in the video stem from the fact that the y axis in android coordinate system is flipped as opposed to a normal one.

    • @either-king
      @either-king 7 месяцев назад

      @@rollebonmarquis7574 may be this angle representing tan inverse function to get angle ?

  • @aviiraj_sharma
    @aviiraj_sharma 3 часа назад

    I think things are looking simple from front end part but at backend totally messed up 😅.

  • @junaidahsan66ify
    @junaidahsan66ify 2 года назад

    You are awesome bro

  • @leendeiri540
    @leendeiri540 3 года назад +1

    Great video thank you very much! The knob keeps rotating after it reaches the end and repeating the process from the beginning, is this the normal behavior or am I missing something? :D

  • @harisai3580
    @harisai3580 2 года назад

    You are too great !

  • @toBeABetterTranslator
    @toBeABetterTranslator 3 года назад

    very intuitive!

  • @surajmaity6194
    @surajmaity6194 Год назад

    Amazing

  • @mustafaammar551
    @mustafaammar551 3 года назад

    WOW Very cool

  • @vikrantghadge9356
    @vikrantghadge9356 2 года назад

    Just curious.. Can we not just add colored surfaces instead of manually drawing rectangle, calculating offsets by hand?

  • @mrjackson9137
    @mrjackson9137 Год назад

    just tested this out, maybe I did smth wrong but the knob is overscrolling when reaching 100% and then getting back to 0. Is that intentional behaviour?

  • @hinrichwrage3004
    @hinrichwrage3004 2 года назад

    Das ist verdammt viel Grün, aber eindeutig nicht hinter Deinen Ohren! :D

  • @bhanuprakashtr2542
    @bhanuprakashtr2542 3 года назад

    Hi Philipp, I am working on android tv. Does jetpack compose support dpad events for android tv. if yes, Could you please make some vertical and grid layout videos for android tv. I have searched the internet no one has published jetpack compose related to android tv articles. if
    you're able to do it it is really appreciatable

  • @abhisekpattnaik2282
    @abhisekpattnaik2282 5 месяцев назад

    I am learning Android developer and currently transition xml to compose but when creating modern ui and custom ui and animation then I am not able do that because my math is very so weak how to improve math skill also

  • @mdjahidulislam9205
    @mdjahidulislam9205 3 года назад

    Thanks a lot

  • @doniyorartikov5879
    @doniyorartikov5879 3 года назад

    Hello
    How saving to listview in sharedpreference with Kotlin ?
    I couldn't do it ,Can you help me ?

  • @mohitmotwani9256
    @mohitmotwani9256 2 года назад

    Thankssss

  • @topgearIQ
    @topgearIQ 2 года назад

    Sin cos tan 😁
    Or knob rotary

  • @tamilcartoontv720
    @tamilcartoontv720 3 года назад +1

    Please Make video on following bro,
    1.Jetpack Compose with Room Database
    2.Jetpack Compose with Navigation Compose Crash Course
    3.Jetpack Compose with most used UI (like Textfield, buttons, Dialog box, fab etc.. )Crash Course
    4.Jetpack Compose Notification and Backround Services Crash Course
    5.Jetpack Compose with Google Maps
    6.Jetpack Compose with Exoplayer
    7.Jetpack Compose with Firebase Authentication
    8.Jetpack Compose with firestore etc..
    Above all courses will help us a lot to learn Jetpack Compose bro..
    So pls make it happen 🤗🤗

  • @crazythunder6196
    @crazythunder6196 3 года назад

    Make video about TrafficStats

  • @username-dh4tq
    @username-dh4tq 2 года назад

    #trimuda :

  • @amitmusic2m929
    @amitmusic2m929 3 года назад

    Amit music 🎶

  • @chad_the_stud
    @chad_the_stud 2 года назад

    this language is so overwhelming. It's just a volume knob and look at the amount of math and the code to make it

    • @PhilippLackner
      @PhilippLackner  2 года назад +6

      What has that to do with the language? 😂 You'll need this math in all languages