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

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ù)公司
亚欧乱色熟女一区二区三区| 欧美中日韩精品免费在线| 欧美性精品不卡在线观看| 好看的中文字幕人妻少妇| 四虎影视国产精品久久| 国产经典三级在线观看| 亚洲av成人av天堂| 蜜桃久久国产精品一区二区| 不卡视频在线免费观看| 久久国产精品一区二区三区| av永久免费观看网站| 国产精品国产成人免费看| 久久综合伊人欧美精品| 国产国语激情对白在线| 日韩国产欧美亚洲一区| 免费高清av中文字幕| 亚洲国产精品综合久久网络| 韩国久久久久三级成人| 欧美日韩在线一区2区| 亚洲av日韩专区在线观看| 亚洲av产在线精品亚洲第| 国产精品1区2区久久久| 成人又黄又爽大片在线观看| 黑人精品一区二区三区| 星空无限传媒国产最新| 中文字幕免费不卡一区| 亚州精品少妇久久久久久| 日韩精品91一区二区| 国产精品不卡一不卡二| 丝袜在线美腿视频网站| 天天操天天日天天射夜夜爽| 91精品手机在线观看| 日韩在线不卡一二三| 欧美久久久久综合一区| 人妻少妇亚洲精品视频| 持续侵犯人妻中文字幕| 国产视频成人免费观看| 四虎海外永久免费地址| 97色伦综合在线欧美| 亚洲综合国产一二三四五区| 打开网址国语一级黄色片|