首页 文章 精选 留言 我的

精选列表

搜索[path],共10016篇文章
优秀的个人博客,低调大师

Unity中的Path对应各平台中的Path

IOS:Application.dataPath :Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/DataApplication.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/RawApplication.persistentDataPath :Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/DocumentsApplication.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/CachesAndroid:Application.dataPath : /data/app/xxx.xxx.xxx.apkApplication.streamingAssetsPath : jar:file:///data/app/xxx.xxx.xxx.apk/!/assetsApplication.persistentDataPath : /data/data/xxx.xxx.xxx/filesApplication.temporaryCachePath : /data/data/xxx.xxx.xxx/cacheWindows Web Player:Application.dataPath : file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)Application.streamingAssetsPath : Application.persistentDataPath : Application.temporaryCachePath :

优秀的个人博客,低调大师

Android:自定义View、Paint、Canvas、attrs、customview、path

第一种:oncreate里启动自定义view Activity代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import android.os.Bundle; import android.app.Activity; import android.view.Menu; public class MainActivity extends Activity { /** * 两种方法: * 1.直接在layout里找到自定义控件 * 2.oncreate里启动自定义view */ @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); //先new一个自定义view对象 VerticalTextView view = new VerticalTextView( this ); setContentView(view); // setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true ; } } View类代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.View; public class VerticalTextView extends View { //定义一个自定义角度的文本 private Paint mPaint; public VerticalTextView(Context context) { super (context); init(); } private void init() { mPaint = new Paint(); mPaint.setColor(Color.BLUE); mPaint.setTextSize( 50 ); mPaint.setAntiAlias( true ); //设置抗锯齿 } @Override protected void onDraw(Canvas canvas) { super .onDraw(canvas); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg); canvas.rotate( 75 ); // canvas.rotate(60,bitmap.getWidth()*2 , bitmap.getHeight()*2); canvas.drawText( "CanvasHello" , 0 , 0 , mPaint); canvas.drawBitmap(bitmap, 0 , 0 , mPaint); } } 第二种:直接在layout里找到自定义控件(直接新建custom view) 1.新建attrs文件,增加自定义属性: 增加属性内容: 1 2 3 4 5 <declare-styleable name= "LabelView" > <attr name= "text" format= "string" /> <attr name= "textColor" format= "color" /> <attr name= "textSize" format= "dimension" /> </declare-styleable> 或者: 1 2 3 4 5 6 7 8 9 <declare-styleable name= "DraggableDot" > <attr name= "radius" format= "dimension" /> <attr name= "legend" format= "string" /> <attr name= "anr" > < enum name= "none" value= "0" /> < enum name= "thumbnail" value= "1" /> < enum name= "drop" value= "2" /> </attr> </declare-styleable> 范例: 1 2 3 4 5 6 7 <resources> <declare-styleable name= "MyView" > <attr name= "mytext" format= "string" /> <attr name= "mytextColor" format= "color" /> <attr name= "mytextSize" format= "dimension" /> </declare-styleable> </resources> 2.增加自己的命名空间,将android修改为自己的包名: 1 2 <RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:MyView= "http://schemas.android.com/apk/res/com.example.aexh23_paint_canvas" 3.在layout中创建自定义view,设置自定义属性(控件包名记得修改): 1 2 3 4 5 6 7 8 9 <com.example.aexh23_paint_canvas.VerticalTextView android:id= "@+id/verticalTextView1" android:layout_width= "wrap_content" android:layout_height= "wrap_content" MyView:mytext= "HelloWorld" MyView:mytextColor= "#654321" MyView:mytextSize= "35sp" android:layout_centerHorizontal= "true" android:layout_centerVertical= "true" /> 范例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:MyView= "http://schemas.android.com/apk/res/com.example.aexh23_paint_canvas" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" tools:context= ".MainActivity" > <com.example.aexh23_paint_canvas.VerticalTextView android:id= "@+id/verticalTextView1" android:layout_width= "wrap_content" android:layout_height= "wrap_content" MyView:mytext= "HelloWorld" MyView:mytextColor= "#654321" MyView:mytextSize= "35sp" android:layout_centerHorizontal= "true" android:layout_centerVertical= "true" /> </RelativeLayout> 4.在自定义view类中增加方法: 1 2 3 4 5 setTextColor(a.getColor(R.styleable.LabelView_textColor, 0xFF000000 )); int textSize = a.getDimensionPixelOffset(R.styleable.LabelView_textSize, 0 ); if (textSize > 0 ) { setTextSize(textSize); } 范例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 public class VerticalTextView extends View { /** * 系统范例:LabelView * 1.新建attrs文件,增加属性: <declare-styleable name="LabelView"> <attr name="text" format="string" /> <attr name="textColor" format="color" /> <attr name="textSize" format="dimension" /> </declare-styleable> ////////////////////////////////////////////// <declare-styleable name="DraggableDot"> <attr name="radius" format="dimension" /> <attr name="legend" format="string" /> <attr name="anr"> <enum name="none" value="0" /> <enum name="thumbnail" value="1" /> <enum name="drop" value="2" /> </attr> </declare-styleable> //////////////////////////////////////////////// 2.增加自己的命名空间,将android修改为自己的包名 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:MyView="http://schemas.android.com/apk/res/com.example.aexh23_paint_canvas" 3.在layout中创建自定义view,增加属性 <com.example.aexh23_paint_canvas.VerticalTextView android:id="@+id/verticalTextView1" android:layout_width="wrap_content" android:layout_height="wrap_content" MyView:mytext="HelloWorld" MyView:mytextColor="#654321" MyView:mytextSize="35sp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> 4.在自定义view类中增加方法 setTextColor(a.getColor(R.styleable.LabelView_textColor, 0xFF000000)); int textSize = a.getDimensionPixelOffset(R.styleable.LabelView_textSize, 0); if (textSize > 0) { setTextSize(textSize); } */ private Paint mPaint; private CharSequence s; private int c; private int d; public VerticalTextView(Context context, AttributeSet attrs) { super (context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyView); s = a.getString(R.styleable.MyView_mytext); c = a.getColor(R.styleable.MyView_mytextColor, 0xFF000000 ); d = a.getDimensionPixelOffset(R.styleable.MyView_mytextSize, 0 ); init(); a.recycle(); } //定义画笔 private void init() { mPaint = new Paint(); mPaint.setColor(c ); mPaint.setTextSize(d); mPaint.setAntiAlias( true ); // 设置抗锯齿 } @Override protected void onDraw(Canvas canvas) { super .onDraw(canvas); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg); canvas.rotate( 30 ); // canvas.rotate(60,bitmap.getWidth()*2 , bitmap.getHeight()*2); canvas.drawText(s.toString(), 0 , 0 , mPaint); canvas.drawBitmap(bitmap, 0 , 0 , mPaint); } } 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1228552,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册