开源中国 www.oschina.net 成立于2008年8月,是中国最大的开源技术社区。我们传播开源的理念,推广开源项目,为 IT 开发者提供了一个发现、使用、并交流开源技术的平台。目前开源中国已收录超过两万款开源软件。
经过不断的改进,目前开源中国社区已经形成了由开源软件库、代码分享、资讯、翻译、讨论区和博客等几大频道内容。
2013年3月28日星期四
2013年2月20日星期三
視頻 - 在平板電腦上運行的Ubuntu
Ubuntu for tablets - Full video
Ubuntu 創始人 Mark Shuttleworth 解釋 在平板電腦上運行的Ubuntu.
Ubuntu 創始人 Mark Shuttleworth 解釋 在平板電腦上運行的Ubuntu.
2013年2月6日星期三
實現自動滾動的文本視圖 - marquee
通過 marquee 實現自動滾動的文本視圖的例子:
<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"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:textSize="28sp"
android:text="Android編程: .............滾動文字" />
</RelativeLayout>
2013年2月2日星期六
2013年1月30日星期三
2013年1月3日星期四
在Android上顯示TTF/OTF
"OTF" 是 OpenType 字體, 在大多數現代操作系統中使用.
"TTF" 是 TrueType 字體, 適用於Windows的首選.
要在Android上顯示TTF/OTF, 首先要下載和複製到/assets/fonts 文件夾. 可以在這裡找到一些免費的字體. 注意, 僅複製所需要的字體文件, 否則,很浪費內存資源, 甚至不能加載/運行!
程序代碼:
"TTF" 是 TrueType 字體, 適用於Windows的首選.
要在Android上顯示TTF/OTF, 首先要下載和複製到/assets/fonts 文件夾. 可以在這裡找到一些免費的字體. 注意, 僅複製所需要的字體文件, 否則,很浪費內存資源, 甚至不能加載/運行!
程序代碼:
package com.example.androidfonts;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Typeface;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView ttfView = (TextView)findViewById(R.id.ttf);
TextView otfView = (TextView)findViewById(R.id.otf);
Typeface ttfFace_FreeMonoBold = Typeface.createFromAsset(getAssets(),
"fonts/FreeMonoBold.ttf");
Typeface otfFace_FreeSansBoldOblique = Typeface.createFromAsset(getAssets(),
"fonts/FreeSansBoldOblique.otf");
ttfView.setTypeface(ttfFace_FreeMonoBold);
ttfView.setTextSize(28);
otfView.setTypeface(otfFace_FreeSansBoldOblique);
otfView.setTextSize(28);
}
}
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<TextView
android:id="@+id/ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello! I'm TTF" />
<TextView
android:id="@+id/otf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello! I'm OTF" />
</LinearLayout>
訂閱:
文章 (Atom)


