當前位置:首頁 » 安卓系統 » android設置textview字體

android設置textview字體

發布時間: 2023-09-28 11:21:08

Ⅰ 安卓屬性動畫怎麼控制textview的字體大小

android:textStyle設置字形[bold(粗體)
0,
italic(斜體)
1,
bolditalic(又粗又斜)
2]
可以設置一個或多個,用「|」隔開
android:typeface設置文本字體,必須是以下常量值之一:normal
0,
sans
1,
serif
2,
monospace(等寬字體)3]

Ⅱ Android中TextView中的字體大小能設置嗎

Android中TextView中的字體大小是能設置的,在開發平台為Windows7,開發工具為android studio按照下面的步驟進行設置。

1、首先在android studio中創建一個項目,如下圖:

Ⅲ android布局文件怎麼設置字體

在windows操作系統中可以按照如下方法為android studio設置字體(包括字體大小,字體顏色)。

1、首先創建一個android文件,並打開XML布局文件,如下圖:

Ⅳ android 如何設置TextView中字體在不同狀態下的顏色

TextView的字體設置方法:
1、直接通過配置文件設置
2、在Activity類中進行設置

第一種方式很簡單,用於靜態或初始文字顏色的設置,方法如下:

main.xml

Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/white"
>
<TextView
android:id="@+id/tv01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:autoLink="all"
android:textColor="@color/red"
/>
</LinearLayout>
color.xml
Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
drawable.xml

Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="white">#FFFFFF</drawable>
<drawable name="dark">#000000</drawable>
<drawable name="red">#FF0000</drawable>
</resources>
strings.xml

Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">地址:http://yahaitt.javaeye.com</string>
<string name="app_name">丫梨的筆記本</string>
</resources>

上面將資源部分分成了3個部分,目的是為了清晰,當然你也可以只建一個xml文件放在res目錄下,而且文件名稱可以隨便命名。

注意兩個地方:
1、main.xml的TextView標簽中:
android:textColor="@color/red"
2、color.xml中:
<color name="red">#FF0000</color>

@color指獲取資源文件中(所有res目錄下的xml文件)的<color>標簽
/red指在標簽下找其name值為red的內容,此時其值為#FF0000

因此,這里我們還可以這樣做:
android:textColor="@drawable/red"

@drawable指獲取資源文件中<drawable>標簽
/red指在標簽下找其name值為red的內容

以此類推,相信你也就知道了如果是在strings.xml中該怎麼做了。

下面看看第二種方式:在Activity類中進行設置

1、先將main.xml改成如下,即去掉android:textColor="@color/red":

Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/white"
>
<TextView
android:id="@+id/tv01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:autoLink="all"
/>
</LinearLayout>
2、修改Activity的onCreate方法,這里我的Activity是Study03_01,原始代碼如下:

Java代碼
package yahaitt.study03_01;

import android.app.Activity;
import android.os.Bundle;

public class Study03_01 extends Activity { @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

第一步:獲得文本控制項TextView,取名為tv

第二步:通過TextView的setTextColor方法進行文本顏色的設置,這里可以有3種方式進行設置:

第1種:tv.setTextColor(android.graphics.Color.RED);//系統自帶的顏色類

第2種:tv.setTextColor(0xffff00ff);//0xffff00ff是int類型的數據,分組一下0x|ff|ff00ff,0x是代表顏色整數的標記,ff是表示透明度,ff00ff表示顏色,注意:這里ffff00ff必須是8個的顏色表示,不接受ff00ff這種6個的顏色表示。

第3種:tv.setTextColor(this.getResources().getColor(R.color.red));//通過獲得資源文件進行設置。根據不同的情況R.color.red也可以是R.string.red或者R.drawable.red,當然前提是需要在相應的配置文件里做相應的配置,如:
<color name="red">#FF0000</color>
<drawable name="red">#FF0000</drawable>
<string name="red">#FF0000</string>

詳細的代碼如下:
Java代碼
package yahaitt.study03_01;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

public class Study03_01 extends Activity {

private TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

tv = (TextView)this.findViewById(R.id.tv01);

// tv.setTextColor(Color.RED);

// tv.setTextColor(0xff000000);

Ⅳ android中textview控制項中的文字的位置是如何調整的 像縮進 靠左 居中 這些概念有嗎

有2種方法可以設置TextView文字居中:
一:在xml文件設置:android:gravity="center"
二:在程序中設置:m_TxtTitle.setGravity(Gravity.CENTER);

備註:android:gravity和android:layout_gravity的區別在於前者對控制項內部操作,後者是對整個控制項操作。
例如:
android:gravity="center"是對textView中文字居中
android:layout_gravity="center"是對textview控制項在整個布局中居中
其實很容易理解,出現"layout"就是控制項對整個布局的操作

TextView文字垂直靠左居中,

設置android:gravity="center_vertical|left"。

android:gravity="center", 垂直水平居中
LinearLayout有兩個非常相似的屬性:android:gravity與android:layout_gravity。他們的區別在於:android:gravity用於設置View組件的對齊方式,而android:layout_gravity用於設置Container組件的對齊方式。
舉個例子,我們可以通過設置android:gravity="center"來讓EditText中的文字在EditText組件中居中顯示;同時我們設置EditText的android:layout_gravity="right"來讓EditText組件在LinearLayout中居中顯示。
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40sp"
android:gravity="center_vertical|left"
android:text="@string/hello_world" />
參考更多請關注扣丁學堂IT教育。。。。。。。。。。。。。。。。。。

Ⅵ android textview 怎麼倒置文字

android textview 怎麼倒置文字

可以考慮把整個TextView倒置。
xml中加入
android:rotation="180"
需要水平翻轉再加入
android:rotationY="180"

android textview drawleft怎麼文字居中

一:在xml檔案設定:android:gravity="center"
二:在程式中設定:m_TxtTitle.setGravity(Gravity.CENTER);
備註:android:gravity和android:layout_gravity的區別在於前者對控制元件內部操作,後者是對整個控制元件操作。
例如:android:gravity="center"是對textView中文字居中
android:layout_gravity="center"是對textview控制元件在整個布局中居中
其實很容易理解,出現"layout"就是控制元件對整個布局的操作

android textview 怎麼實現文字滾動

android:focusable="true" 加上這句 TextView只有是焦點元件時,才會滾動。 如果你不想是焦點也能滾動的話,那應該是個走馬燈控制元件了,我也研究下看看走馬燈得如何實現。

TextView實現文字滾動需要以下幾個要點:
1.文字長度長於可顯示範圍:android:singleLine="true"
2.設定可滾到,或顯示樣式:android:ellipsize="marquee"
3.TextView只有在獲取焦點後才會滾動顯示隱藏文字,因此需要在包中新建一個類,繼承TextView。重寫isFocused方法,這個方法預設行為是,如果TextView獲得焦點,方法返回true,失去焦點則返回false。跑馬燈效果估計也是用這個方法判斷是否獲得焦點,所以把它的返回值始終設定為true。ellipsize屬性
設定當文字過長時,該控制元件該如何顯示。有如下值設定:」start」—–省略號顯示在開頭;」end」——省略號顯示在結尾;」middle」—-省略號顯示在中間;」marquee」 ——以跑馬燈的方式顯示(動畫橫向移動)marqueeRepeatLimit屬性
在ellipsize指定marquee的情況下,設定重復滾動的次數,當設定為marquee_forever時表示無限次。focusable屬性
能否獲得焦點,同樣focusableInTouchMode應該是滑動時能否獲得焦點

android textview文字縱向顯示怎麼弄

:download.csdn./download/reasonwing/5339393

怎樣可以將方檔的文字倒置

使用這個軟體就可以輕松將方檔的文字倒置
軟體介紹【基本介紹】
??????SolidConverterPDF是一套專門將PDF檔案轉換成DOC的軟體,除了轉換成DOC檔案外,還可以轉換成RTF以及WordXML檔案。除此之外,它還有一個圖片擷取功能,可以讓我們將PDF檔里的圖片擷取出來,以及將PDF檔里的表格擷取出來,並輸出到Excel里,方便我們編輯表格里的資料。
???? ??市面上有不少軟體像是OpenOffice、pdf995、PDFCreator等,都擁有將WORD格式的DOC檔轉成PDF檔案的功能。但若是反過來要將PDF檔案轉DOC檔的軟體就不多見了;SolidConverterPDF就是一套能完成這項工作的軟體。
??????SolidConverterPDF擁有清楚簡明的介面,並且支援包括繁體中文的多國語系切換,使用者不必擔心看不懂而不會操作。你只要選擇好PDF檔的輸入路徑,然後設定檔案輸出的存放位置,最後按下「轉換」鍵就行了。
???? ??目前市面上所有的PDF檔案轉DOC檔軟體都沒有免費的,SolidConverterPDF可以算是比較便宜的其中之一套了。對了,若是你要轉換的PDF檔經過了加密,轉換時程式會要求你輸入密碼;若是你不知道密碼的話,可是無法順利轉檔成功的。
【軟體功能】
頁首和頁尾復原
SolidConverterPDF為您提供轉換頁首和/或頁尾的選項。您可選擇將其放在Word的頁首/頁尾功能中,或者選擇將其放在檔案的主體中,
使頁首/頁尾作為獨立的文字方塊出現在每一頁。第三種選項則是您可將其一起移除掉。
旋轉文字自動復原
表格識別SolidConverterPDF能夠將表格從PDF轉換至Word,同時保持表格的頁面,包括方框和表格欄區。表格欄區將被識別出來,並轉換至文字方框,以供輕松編輯。

Android 怎麼旋轉TextView文字顯示方向

在一個專案中,需要旋轉TextView的文字顯示方向,怎麼實現呢?這里提供一種變通的方法來實現該功能:Animation動畫,儲存動畫結束狀態來實現該功能。
主要程式碼如下:
1、定義一個anim xml資原始檔rotate_right.xml
Html程式碼
<?xml version="1.0" encoding="utf-8"?>
<set>
<rotate xmlns:android="IP" android:interpolator="@android:anim/linear_interpolator"
android:fromDegrees="0" android:toDegrees="-90" android:ration="0"
android:pivotX="50%" android:pivotY="50%" android:repeatCount="0" />
</set>
2、設定textview播放動畫
Java程式碼
private Animation mAnimationRight;
private TextView mlblRightPhotoNum;

mAnimationRight = AnimationUtils.loadAnimation(mContext, R.anim.rotate_right);
mAnimationRight.setFillAfter(true);

mlblRightPhotoNum = (TextView) findViewById(R.id.lblRightPhotoNum);
mlblRightPhotoNum.setAnimation(mAnimationRight);
總結:主要用到了Animation 的 setFillAfter(boolean b)方法,該方法表示是否保持動畫結束時狀態;
拓展:
1、Animation 方法:setFillBefore(boolean b)當動畫結束後,是否返回動畫開始狀態。
2、當activity必須指定launchMode時【例如:Camera程式必須制定橫屏,才能取景正常】,可以通過OrientationEventListener及動畫旋轉來模擬橫豎屏效果
.

Ⅶ Android中TextView中的字體大小能設置嗎

可以

布局文件中使用android:textSize屬性設置,例如

android:textSize="15sp"

代碼中使用setTextSize(intunit, intsize) 方法設置,第一個參數是字體大小單位,第二個參數是字型大小值,例如

setTextSize(TypedValue.COMPLEX_UNIT_SP,15);//單位最好使用SP

字體單位最好按照google官方文檔統一使用SP

熱點內容
深度優先演算法廣度優先演算法 發布:2024-05-01 18:47:02 瀏覽:436
pythonlist索引獲取 發布:2024-05-01 18:43:20 瀏覽:152
上網提示找不到伺服器的ip地址 發布:2024-05-01 18:12:01 瀏覽:169
正版我的世界怎麼開一個伺服器 發布:2024-05-01 18:11:50 瀏覽:738
七日殺伺服器被封ip怎麼辦 發布:2024-05-01 18:01:57 瀏覽:235
c語言的雙引號 發布:2024-05-01 17:52:39 瀏覽:449
我的世界伺服器開服包 發布:2024-05-01 17:18:30 瀏覽:900
收費下載站源碼 發布:2024-05-01 16:49:01 瀏覽:975
壓縮下載啥 發布:2024-05-01 16:42:32 瀏覽:725
安卓手機預裝系統軟體放在哪裡的 發布:2024-05-01 16:37:41 瀏覽:837