网上查找资料 记录学习 int strokeWidth = 5; // 3dp 边框宽度 int roundRadius = 15; // 8dp 圆角半径 int strokeColor = Color.parseColor("#2E3135");//边框颜色 int fillColor = Color.parseColor("#DFDFE0");//内部填充颜色 GradientDrawable gd = new GradientDrawable();//创建d…
1.设置旋转动画 final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f); animation.setInterpolator(new LinearInterpolator()); // LinearInterpolator 表示均匀速率 animation.setDuration(3000);//设…
不知道怎么起标题,就这样了. 目前主要讲两个方面内容: 代码方式 设置RadioButton的 android:button . android:background 等属性为 @null : 代码方式 通过布局模板动态创建固定参数的RadioButton等控件对象 1.代码设置@null // 这里不能用null,必需采用以下方式设置 radioButton.setButtonDrawable(getResources().getDrawable(android.R.color.transpa…
开发中经常需要使用Shape和Selector,如果每个都用xml设置的话,会占用apk大小,同时命名多了也会混乱,使用代码来设置会方便很多. 需要用到2个类:GradientDrawable和StateListDrawable 相关API: setColor(rgb); //填充颜色setGradientType(GradientDrawable.RECTANGLE); //shape矩形setCornerRadius(radius); //四周圆角半径setStroke(1,strokenC…
我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@drawable/image" /> 但是有些情况下,需要在java代码里来写,可是View本身没有setMargin方法,怎么办呢? 通过查阅android api,我们发现android.view.ViewGroup.MarginLayoutParams有个方法setMargins(left,…
更换radiobutton中的图片在xml中很好设置,但对于初学者如何在代码中设置还是不容易找的.没法子,通过看原版api找到两个方法,setCompoundDrawables和setCompoundDrawablesWithIntrinsicBounds. 下面交给大家方法. 第一个方法:setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) ap…
/** * * @desc 设置左边图标 * @param @param drw * @return void */ public void setAlertLeftIcon(Drawable drw){ drw.setBounds(0, 0, drw.getMinimumWidth(), drw.getMinimumHeight()); alertTitle.setCompoundDrawables(drw, null, null, null); }…
1: public class MainActivity extends Activity { 2: @Override 3: public void onCreate(Bundle savedInstanceState) { 4: super.onCreate(savedInstanceState); 5: //隐去标题栏(应用程序的名字) 6: this.requestWindowFeature(Window.FEATURE_NO_TITLE); 7: //隐去状态栏部分(电池等图标和一起修…
在用Eclipse时候,你可以进行设置,设置成不管你输入任何字母,都能进行代码的提示,在Android Studio中也可以 设置,而且比Eclipse设置来的简单.当然如果你觉得代码自动提示会降低你的代码水平,你也可以不设置,在写代码 过程中,如果一时忘记了,你就可以用代码提示的快捷键.android studio代码提示的快捷键是什么呢?看这篇文章: [Android Studio快捷键]之代码提示 接下来说如何设置代码自动提示,如图: 图上内容比较多,我直接按区域划分成6块区域来说吧: 区…
同Eclipse时间,您可以设置,无论你是设置输入不管什么信,可以提示码,在Android Studio也可以 设置.并且比Eclipse设置来的简单. 当然假设你认为代码自己主动提示会减少你的代码水平.你也能够不设置,在写代码 过程中,假设一时忘记了,你就能够用代码提示的快捷键. android studio代码提示的快捷键是什么呢?看这篇文章: [Android Studio快捷键]之代码提示 接下来说怎样设置代码自己主动提示.如图: 图上内容比較多,我直接按区域划分成6块区域来说吧: 区域…