当前位置: 编程技术>移动开发
本页文章导读:
▪简略extends textView让其四周边框改变 简单extends textView让其四周边框改变
希望耐心看完
http://developer.android.com/intl/fr/guide/topics/ui/custom-components.html
你会有收获 因为继承控件根据需求不同 层次不同。
我们这里只是想改变texyView 四.........
▪ Shortcut 快捷方式 应用 - 1 Shortcut 快捷方式 使用 - 1
快捷方式的使用[原理]1. 系统有一个BroadcastReceiver 其action = "com.android.launcher.action.INSTALL_SHORTCUT" 用于接收与快捷方式有关的Intent2. 我们要做的就是:把快捷方式的有.........
▪ 改变进度栏的色彩 progress bar 的背景色 改变进度栏的颜色 progress bar 的背景色
进度栏默认的颜色为黄色那么怎么改呢
查看源码 你会发现
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/backgro.........
[1]简略extends textView让其四周边框改变
来源: 互联网 发布时间: 2014-02-18
简单extends textView让其四周边框改变
希望耐心看完
http://developer.android.com/intl/fr/guide/topics/ui/custom-components.html
你会有收获 因为继承控件根据需求不同 层次不同。
我们这里只是想改变texyView 四周的边框让其四周成为简单线
package samples.test;
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyTextView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Rect rect = new Rect();
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.WHITE);
paint.setStrokeWidth(3);
getLocalVisibleRect(rect);
canvas.drawRect(rect, paint);
}
}
然后在layout xml中我使用的是main.xml 然后在里面加入
<samples.test.MyTextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
[2] Shortcut 快捷方式 应用 - 1
来源: 互联网 发布时间: 2014-02-18
Shortcut 快捷方式 使用 - 1
快捷方式的使用
[原理]
1. 系统有一个BroadcastReceiver 其action = "com.android.launcher.action.INSTALL_SHORTCUT" 用于接收与快捷方式有关的Intent
2. 我们要做的就是:把快捷方式的有关信息装入对应的Intent 然后发送出去即可
[代码]
1. 定义对应的Intent
2. 把有关信息装入Intent 比如 图标 名字 其所引起的Intent
(当按下该快捷方式后 就会拨打110)
3. 发送之
over!
快捷方式的使用
[原理]
1. 系统有一个BroadcastReceiver 其action = "com.android.launcher.action.INSTALL_SHORTCUT" 用于接收与快捷方式有关的Intent
2. 我们要做的就是:把快捷方式的有关信息装入对应的Intent 然后发送出去即可
[代码]
1. 定义对应的Intent
private final String ACTION_ADD_SHORTCUT =
"com.android.launcher.action.INSTALL_SHORTCUT";
Intent intent = new Intent(ACTION_ADD_SHORTCUT);
2. 把有关信息装入Intent 比如 图标 名字 其所引起的Intent
Intent dial = new Intent(Intent.ACTION_CALL);
dial.setData(Uri.parse("tel://110"));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Dial to 110");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,dial);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
(当按下该快捷方式后 就会拨打110)
3. 发送之
sendBroadcast(intent);
over!
[3] 改变进度栏的色彩 progress bar 的背景色
来源: 互联网 发布时间: 2014-02-18
改变进度栏的颜色 progress bar 的背景色
进度栏默认的颜色为黄色那么怎么改呢
查看源码 你会发现
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#ff9d9e9d"
android:centerColor="#ff5a5d5a"
android:centerY="0.75"
android:endColor="#ff747674"
android:angle="270"
/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#80ffd300"
android:centerColor="#80ffb600"
android:centerY="0.75"
android:endColor="#a0ffcb00"
android:angle="270"
/>
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
>
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="@color/progress_start"
android:endColor="@color/progress_end"
android:angle="270" />
</shape>
</clip>
</item>
那么你可以发现@color/progress_start @color/progress_end 你只要修改他们
直接改成16进制,或者 自己弄一个color文件然后在里面写颜色
然后呢
你保存上面的文件加入叫my_progress.xml ,然后MyProgressBar.setProgressDrawable(引用刚才文件就可以了) ,通过上面的函数你该知道my_progress.xml 应该保存在drawable 文件夹下了吧
最新技术文章: