android好看的音量旋钮

本文介绍了如何创建一个美观的Android音量旋钮,通过自定义控件AnalogController实现,包括布局设计、控件绘制及点击事件监听,能够显示并获取当前旋钮的值。
摘要由CSDN通过智能技术生成

效果图:

实现思路,用的自定义的控件,图片和按钮都是自己绘制的,并且附带点击事件,可以监听当前的旋钮的值:

第一步:先把布局写了:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="#000000"
    android:layout_width="match_parent"
    android:gravity="center"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        />
    <LinearLayout
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal">

        <com.example.longshine.zname.AnalogController
            android:id="@+id/controllerBass"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#000000" />

    </LinearLayout>


</LinearLayout>

第二步:然后把自定义的控件类写了:AnalogController

 import android.content.Context;
        import android.graphics.Canvas;
        import android.graphics.Color;
        import android.graphics.Paint;
        import android.util.AttributeSet;
        import android.view.MotionEvent;
        import android.view.View;


/**
 * Created by Harjot on 23-May-16.
 */
public clas
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值