欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android中如何設(shè)置TextView的字體默認(rèn)大小

本篇文章為大家展示了Android中如何設(shè)置TextView的字體默認(rèn)大小,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

成都創(chuàng)新互聯(lián)是一家專(zhuān)業(yè)從事成都網(wǎng)站制作、成都網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司。作為專(zhuān)業(yè)的建站公司,成都創(chuàng)新互聯(lián)依托的技術(shù)實(shí)力、以及多年的網(wǎng)站運(yùn)營(yíng)經(jīng)驗(yàn),為您提供專(zhuān)業(yè)的成都網(wǎng)站建設(shè)、成都全網(wǎng)營(yíng)銷(xiāo)推廣及網(wǎng)站設(shè)計(jì)開(kāi)發(fā)服務(wù)!

對(duì)于設(shè)置TextView的字體默認(rèn)大小對(duì)于UI界面的好看程度是很重要的,小屏幕設(shè)置的文字過(guò)大或者大屏幕設(shè)置的文字過(guò)小都造成UI的不美觀

現(xiàn)在就讓我們學(xué)習(xí)自適應(yīng)大小的TextView控件,即當(dāng)文字長(zhǎng)度變化時(shí),文字的大小會(huì)相應(yīng)的變化,保證顯示在一行當(dāng)中

實(shí)現(xiàn)依靠于第三方類(lèi)庫(kù)

第三方類(lèi)來(lái)源:

和正常的使用TextView一樣,只需要將要自適應(yīng)的TextView標(biāo)簽設(shè)置為<me.grantland.widget.AutofitTextView/>

注意:一定要設(shè)置為單行,否定無(wú)法顯示效果

android:singleLine="true"

<me.grantland.widget.AutofitTextView
   android:id="@+id/output_autofit"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/example"
   android:textSize="50sp"
   android:gravity="center"
   android:singleLine="true"
   autofit:minTextSize="8sp"
   />

布局文件:

<&#63;xml version="1.0" encoding="utf-8"&#63;>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:autofit="http://schemas.android.com/apk/res-auto"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  >
  <EditText
   android:id="@+id/input"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:singleLine="true"
   android:hint="@string/input_hint"
   android:text="@string/example"/>
  <TextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/label_normal"
   />
  <TextView
   android:id="@+id/output"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/example"
   android:textSize="50sp"
   android:gravity="center"
   />
  <TextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/label_autofit"
   />
  <me.grantland.widget.AutofitTextView
   android:id="@+id/output_autofit"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/example"
   android:textSize="50sp"
   android:gravity="center"
   android:singleLine="true"
   autofit:minTextSize="8sp"
   />
 </LinearLayout>
</ScrollView>

activity_main.xml

string.xml

<&#63;xml version="1.0" encoding="utf-8"&#63;>
<resources>
 <string name="app_name">Texttest</string>
 <string name="action_settings">Settings</string>
 <string name="hello_world">Hello world!</string>
 <string name="input_hint">text</string>
 <string name="label_normal">Normal:</string>
 <string name="label_autofit">Autofit:</string>
 <string name="example">This is an example</string>
</resources>

activity

package com.example.texttest;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
 private TextView mOutput;
 private TextView mAutofitOutput;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mOutput = (TextView)findViewById(R.id.output);
  mAutofitOutput = (TextView)findViewById(R.id.output_autofit);
  ((EditText)findViewById(R.id.input)).addTextChangedListener(new TextWatcher() {
   @Override
   public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
    // do nothing
   }
   @Override
   public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
    mOutput.setText(charSequence);
    mAutofitOutput.setText(charSequence);
   }
   @Override
   public void afterTextChanged(Editable editable) {
    // do nothing
   }
  });
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }
}

MainActivity.java

上述內(nèi)容就是Android中如何設(shè)置TextView的字體默認(rèn)大小,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

文章標(biāo)題:Android中如何設(shè)置TextView的字體默認(rèn)大小
分享路徑:http://aaarwkj.com/article28/ihphcp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、域名注冊(cè)定制開(kāi)發(fā)、云服務(wù)器動(dòng)態(tài)網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
日韩性生活视频免费播放 | 91人妻精品丰满少妇区| 91国语对白在线观看| 91九色视频官网在线观看| 日韩精品少妇一区二区| 日韩av手机在线不卡| 国产男女免费操作视频| 国内揄拍国内精品少妇国| 清纯唯美亚洲自拍第一页| av剧情免费在线观看| 九色综合一区二区三区| 日本人的黄色录像视频| 久久香蕉国产线看观看亚洲| 蜜桃精品国产一区二区三区| 国产精品久久99粉嫩| 大陆av剧情网站在线观看| 日韩中文字幕资源一区| 亚洲中文字幕在线不卡| 国产黄色片网站在线观看| 国产亚洲高清国产拍精品久久| 欧美伊人色综合久久天天| 午夜精品三级一区二区三区| 国产精品亚洲欧美在线| 成人av免费高清在线| 夫妻过性生活视频播放| 成年人正常性生活频率| 91日本视频在线播放| 国产亚洲精品免费专线视频| 成人性生交大片免费看中文 | 91欧美精品一区二区| 国内传媒视频免费观看| 日本理论午夜三级在线观看| 日韩欧美国产精品自拍| 男人的天堂成人午夜视频| 欧美伊人久久综合成人网| 亚洲av中文久久精品国内| 亚洲黄色大片在线免费观看| 九色91成人在线视频| 精品少妇人妻久久av免费| 久久精品性少妇一区=区三区| 国产在线精品专区第一页 |