android弧度
1. 安卓科学计算器如何计算正余弦
安卓自带的计算器默认按弧度计算。
比如计算30°的正弦:
sin(30/180*π)=
2. android自定义shape 时xmlns怎么自动
MainActivity如下:
package cn.testshape;
import android.os.Bundle;
import android.app.Activity;
/**
* Demo描述:
* 自定义shape的使用
*/
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:layout_width="250dip"
android:layout_height="50dip"
android:text="测试自定义shape的使用"
android:background="@drawable/background_selector"
android:textColor="@drawable/textcolor_selector"
android:layout_centerInParent="true"
android:gravity="center"
/>
</RelativeLayout>
background_selector.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/pressed_shape" android:state_pressed="true"/>
<item android:drawable="@drawable/default_shape"/>
</selector>
default_shape.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- 定义矩形rectangle -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- 定义边框颜色 -->
<solid android:color="#d1d1d1" />
<!-- 定义圆角弧度 -->
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"
/>
</shape>
pressed_shape.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- 定义矩形rectangle -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- 定义边框颜色 -->
<solid android:color="#7bb3f8" />
<!-- 定义圆角弧度 -->
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"
/>
</shape>
textcolor_selector.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:color="#ffffff" android:state_pressed="true"/>
<item android:color="#000000"/>
</selector>
3. android 弹窗中我的背景图是有弧度的,为什么做出来的弹窗是有角的 ,要怎么写代码去掉棱角
整个弹出窗口的背景放一张圆角图片就好了。。
4. 安卓系统的手机计算器,sin30,cos30等计算都不对,不知道怎么回事 有谁会用
这种计算器默认的是弧度制,30°是角度制,进行角度与弧度转化即可:
以30°为例,180°=1π rad,则1°=(1/180)π rad,那么30°=(1/6)π rad。
用π/6代替你的30进行计算即可。
5. android自定义对话框怎么设置弧度
我想你想要实现圆角的对话框,可以参考如下:
package com.example.jjy.myapplication;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by jjy on 16-5-15.
*/
public class MyDialog extends Dialog{
private Button positiveButton, negativeButton;
private TextView contenttv;
public MyDialog(Context context) {
super(context,R.style.mydialog);
View view = LayoutInflater.from(getContext()).inflate(R.layout.mydialoglayout, null); //通过LayoutInflater获取布局
contenttv = (TextView) view.findViewById(R.id.title);
positiveButton = (Button) view.findViewById(R.id.acceptbtn);
negativeButton = (Button) view.findViewById(R.id.refusebtn);
setContentView(view); //设置view
}
//设置内容
public void setContent(String content) {
contenttv.setText(content);
}
//确定按钮监听
public void setOnPositiveListener(View.OnClickListener listener){
positiveButton.setOnClickListener(listener);
}
//否定按钮监听
public void setOnNegativeListener(View.OnClickListener listener){
negativeButton.setOnClickListener(listener);
}
}
R.style.mydialog 对话框属性在 values/styles.xml中设置:
[html] view plain
<resources>
<style name="mydialog" parent="android:style/Theme.Dialog">
<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 没有标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 背景模糊 -->
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
6. android 怎么计算一个弧度起点 和 结束点
最小变动 乘以 交易单位 乘以 交易数量.如黄金期货, 0.01 * 1000*1= 10, 当黄金期货变动0.01点时,获利10元. 0.01 为变动, 1000克 为黄金期货交易的单位(1000克为1手), 1为手数-这个是黄金最小的买进量.同理 大豆期货, 1*10*1=10 元,当大豆期货变动1元, 1手大豆合约 获利10元.
所谓黄金期货,是指以国际黄金市场未来某时点的黄金价格为交易标的的期货合约,投资人买卖黄金期货的盈亏,是由进场到出场两个时间的金价价差来衡量,契约到期后则是实物交割。
7. android 使用canvas画线,如何保证快速画出圆滑的曲线
[mw_shl_code=java,true] RectF rect = new RectF(0, 0, radii, radii); // 圆形弧度需要的区域(左上角的x,y坐标 ,及右下角x,y坐标) Paint paint = new Paint(); paint.setColor(r.getColor(R.color.bg_color_1)); canvas.drawCircle(radii/2, radii/2, radii/2, paint);[/mw_shl_code]
8. 怎样让edittext有弧角
实现弧角,需要编写一个样式文件,然后edittext的background使用该样式就可以了。弧角的弧度可以通过修改android:radius来变化。
-----------------------效果图-----------------------
---------------------代码------------------------------
<EditText
android:id="@+id/sendMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:background="@drawable/style_edittext_shape"
android:hint="需要发送的内容"
android:inputType="text" />
---------------------样式style_edittext_shape.xml文件------------------------
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<!-- <solid android:color="#F0F3F0" /> -->
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="15dip" />
<stroke
android:width="1dip"
android:color="#BDC7D8" />
<!-- padding:Button里面的文字与Button边界的间隔 -->
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp"
/>
</shape>
-------------------------END-----------------------
9. Android studio中怎么将方形按钮设置成圆角以及渐变效果
一、在 studio中res 包下的drawable中建立一个shape的文件,系统会给你一个默认的方形然后你就可以开始设置你需要的效果。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:Android="http://schemas.android.com/apk/res/android">
<!--填充背景色 -->
<solid android:color="#ffff00" /> //solid 指的是背景颜色的设置
<!--描边 他需要 2个参数,颜色 第二参数 宽度 -->
<stroke
android:width="2dp" //width 指的是边框的宽度
android:color="#ff00ff" /> //color指的是边框的颜色
<!-- 设置弧度 Radius设置所有角的弧度 --> //radius 指的就是角的弧度
<corners //方形存在四个角,我们可以同时设置四个角,也可以分开设置
android:bottomLeftRadius="20dp" //左下角
android:bottomRightRadius="20dp" //右下角
android:topLeftRadius="20dp" //左上角
android:topRightRadius="20dp" /> //右上角
//同时设置:<corners
android:Radius="20dp" /> //四个角同时设置
<!-- 渐变色 startColor 启示颜色 endColor最终颜色 type类型(如果类型为radial(径向渐变,一个圆心以半径的方式渐变),必须加上 android:gradientRadius="**")-->
<gradient
android:startColor="#ff0000" //开始颜色
android:endColor="#ffffff" //结束颜色
android:type="linear" /> //水平渐变 从左到右 type 指的是渐变的模式
<!--内容与边框的间距-->
<padding
android:bottom="15dp"
android:left="15dp"
android:right="15dp"
android:top="15dp" />
<!--如果设置了渐变色 那么背景颜色将不显示 -->
</shape>
<gradient>
shape的颜色渐变属性
attributes:
android:angle
Integer,代表渐变颜色的角度, 0 is left to right, 90 is bottom to top. 必须是45的整数倍.
默认是 0.该属性只有在type=linear情况下起作用,默认的type为linear。
默认情况下,从左到右:
xml代码:<gradient
android:startColor="#000000"
android:endColor="#ffffff"
/>
angle=270,从上到下 :
xml代码:<gradient
android:startColor="#000000"
android:endColor="#ffffff"
android:angle="270"
/>
android:startColor
Color. 颜色渐变的开始颜色,如angle=270中的 android:startColor="#000000"
android:endColor
Color. 颜色渐变的结束颜色,如angle=270中的 android:endColor="#ffffff"
android:centerColor
Color. 颜色渐变的中间颜色,主要用于多彩。
<gradient
android:startColor="#000000"
android:endColor="#ffffff"
android:centerColor="#ff0000"
/>
android:centerX
Float.(0 - 1.0) 相对X的渐变位置。
android:centerY
Float.(0 - 1.0) 相对Y的渐变位置。
这两个属性只有在type不为linear情况下起作用。
android:gradientRadius
Float. 渐变颜色的半径,单位应该是像素点. 需要 android:type="radial".
如果android:type="radial",没有设置android:gradientRadius,将会报错,error inflating class.
xml代码:
<gradient
android:startColor="#ff0000"
android:endColor="#ffffff"
android:centerX="0.5"
android:centerY="0.5"
android:gradientRadius="30"
android:type="radial"
/>
加入Android:centerColor属性
<gradient
android:startColor="#ff0000"
android:endColor="#ffffff"
android:centerColor="#000000"
android:centerX="0.5"
android:centerY="0.5"
android:gradientRadius="30"
android:type="radial"
/>
android:type
Value Description
"linear" 线性渐变.可以理解为 y=kx+b.
"radial" A radial gradient.圆形渐变,起始颜色从cenralX,centralY点开始。
"sweep" A sweeping line gradient.
centerX="0.2" centerX="0.2"
xml代码:
<gradient
android:startColor="#ff0000"
android:endColor="#ffffff"
android:centerX="0.2"
android:centerX="0.2"
android:gradientRadius="30"
android:type="radial"
/>
type="sweep":
xml代码:
<gradient
android:startColor="#ff0000"
android:endColor="#ffffff"
android:centerX="0.5"
android:centerY="0.5"
android:type="sweep"
/>