当前位置:  编程技术>移动开发
本页文章导读:
    ▪走马灯成效文字        走马灯效果文字 走马灯效果的代码,对TextView进行一下重写即可: public class AutoScrollTextView extends TextView { public final static String TAG = AutoScrollTextView.class.getSimpleName(); private float mTxtLength = 0f;// .........
    ▪ Gallery添小点效果实现        Gallery加小点效果实现 大家好:   心雨心今天又跟大家见面了 今天发布的是Gallery加小点效果实现   如图:  很多现在的android应用需要上图效果。gallery每次滑动一幅图片,小点要跟着发生变.........
    ▪ 怎么在Qt和Qml中发邮件       如何在Qt和Qml中发邮件 原创帖,转发请注明出处:http://thierry-xing.iteye.com/blog/1407453   有两个方法可以在Qt中发邮件: 1) 使用QtMobility API   #include <QMessage> #include <QMessageService> QMessageS.........

[1]走马灯成效文字
    来源: 互联网  发布时间: 2014-02-18
走马灯效果文字
走马灯效果的代码,对TextView进行一下重写即可:
public class AutoScrollTextView extends TextView {

	public final static String TAG = AutoScrollTextView.class.getSimpleName();
	private float mTxtLength = 0f;// 文本长度
	private float step = 0f;// 文字的横坐标
	private float y = 10f;// 文字的纵坐标
	private float mInitX = 0.0f;// 初始文字坐标
	private float mEndX = 0.0f;// 判断文字左面坐标.
	private Paint paint = null;// 绘图样式
	private String text = "";// 文本内容

	public AutoScrollTextView(Context context) {
		super(context);
	}

	public AutoScrollTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public AutoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void init() {
		paint = getPaint();
		text = getText().toString();
		mTxtLength = paint.measureText(text);
		step = mTxtLength;
		mInitX = getLeft() + getLayoutParams().width + mTxtLength;
		mEndX = getLeft() + getLayoutParams().width + mTxtLength * 2;
		y = getTextSize() + getPaddingTop();
		invalidate();
	}

	@Override
	public void onDraw(Canvas canvas) {
		canvas.drawText(text, mInitX - step, y, paint);
		step += 1;
		if (step > mEndX) {
			step = mTxtLength;
		}
		invalidate();
	}

}


在Activity中调用一下init()方法即可.

布局文件还是贴一下吧:
<com.ex.AutoScrollTextView
        android:id="@+id/TextViewNotice"
        android:layout_width="100dp"
        android:layout_height="30dp"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="100dp"
        android:background="#EEE"
        android:paddingTop="5dp"
        android:text="浮动的文字欢饮你......."
        android:textColor="#000"
        android:textSize="15sp" >
    </com.ex.AutoScrollTextView>



今天补上一种系统自带的方法:
<TextView
        android:id="@+id/mTxt"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="100dp"
        android:ellipsize="marquee"
        android:fadingEdge="none"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="开放平台成网络淘金下一 ..."
        android:textColor="@android:color/white"
        android:textSize="18dip" />


直接设置对应TextView的文本内容即可.

    
[2] Gallery添小点效果实现
    来源: 互联网  发布时间: 2014-02-18
Gallery加小点效果实现

大家好:

  心雨心今天又跟大家见面了

今天发布的是Gallery加小点效果实现

 

如图:



 很多现在的android应用需要上图效果。gallery每次滑动一幅图片,小点要跟着发生变化。

自己写的小demo,请参考!


    
[3] 怎么在Qt和Qml中发邮件
    来源: 互联网  发布时间: 2014-02-18
如何在Qt和Qml中发邮件

原创帖,转发请注明出处:http://thierry-xing.iteye.com/blog/1407453

 

有两个方法可以在Qt中发邮件:
1) 使用QtMobility API

 

#include <QMessage>
#include <QMessageService>

QMessageService* msgAction = new QMessageService(this);
QMessage msg;
msg.setType(QMessage::Email);
msg.setTo(QMessageAddress(QMessageAddress::Email,"abc@abc.com"));
msg.setSubject("邮件标题");
msg.setBody("邮件内容");
QStringList attachments;
attachments.append(":/res/icon.png");
msg.appendAttachments(attachments);
//Send email message
qDebug()<<"Sending Status = "<<msgAction->send(msg);

 

2) 使用默认邮件客户端

QDesktopServices:openUrl(QUrl(tr("mailto:abc@abc.com?subject=邮件标题&body=邮件内容")));

 

qml中这样使用:

Qt.openUrlExternally("mailto:abc@abc.com?subject=邮件标题&body=邮件内容)

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3