『壹』 android怎樣對listview中的textview設置中文加粗,textStyle只英文有效
首先在res/drawable目錄下寫個配置文件作為各種狀態的樣式配置,命名bg這個隨便:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android=" http://schemas.android.com/apk/res/android">
<item android:state_focused="false" state_focused="false" android:state_pressed="false" android:state_selected="false"
android:color="@drawable/white" />
<item android:state_focused="true" android:state_pressed="true"
android:color=
"@drawable/black" />
<item android:state_focused="false" android:state_pressed="true"
android:color="@drawable/black" />
<item android:state_selected="true"
android:color="@drawable/black" />
<item android:state_focused="true"
android:color="@drawable/black" />
</selector>
然後在寫ListView選項配置文件的時候吧上面寫的配置文件添加給這個選項配置文件:
<TextView android:id="@+id/tt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="要顯示的文本"
android:textSize="字體大小"
android:textColor="@drawable/bg"<--!此bg就是上面的配置文件名-->"
/>
『貳』 手機wps加粗在哪
手機wps加粗在哪?wps Word字體加粗可在開始菜單中找到,具體加粗字體的方法為:
1、首先打開一個WPS Word文檔,然後切換到開始頁面。
2、接著選中需要加粗的文字,在狀態欄中點擊加粗按鈕「B」即可。
WPS for Android是WPS Office的安卓版,是一款辦公軟體套裝,可以實現辦公軟體最常用的文字、表格、演示等多種功能。該軟體具有內存佔用低,運行速度快,體積小巧等優點。WPS具有強大的插件平台支持,可以免費提供海量在線存儲空間及文檔模板,支持閱讀和輸出PDF文件。
WPS Office個人版對個人用戶永久免費,包含 WPS文字、WPS表格、WPS演示三大功能模塊,與MS Word、MS Excel、MS PowerPoint一一對應,應用XML 數據交換技術,無障礙兼容doc.xls.ppt等文件格式,你可以直接保存和打開 Microsoft Word、Excel 和 PowerPoint 文件,也可以用 Microsoft Office輕松編輯WPS系列文檔。WPS 僅僅只有MS的12分之1,它在不斷優化的同時,體積依然保持小於同類軟體,不必耗時等待下載,也不必為安裝費時頭疼,幾分鍾即可下載安裝,啟動速度較快,讓你的辦公速度「飛起來」。遵循 Windows 7主流設計風格的2012新界面,metro風格的2013界面,並且有兩種色彩風格,清新藍、素雅黑,加之傳統的2012和2003風格,賦予你煥然一新的視覺享受。WPS 2013充分尊重用戶的選擇與喜好,提供四界面切換,用戶可以無障礙的在新界面與經典界面之間轉換,熟悉的界面、熟悉的操作習慣呈現,無需再學習。
『叄』 Android Toast可以自定義,有沒有對Toast裡面的字體進行,加粗,改變大小,斜體。
可以在Toast里增加一個TextView然後對TextView做字體加粗,大小設置。
1.字體加粗
textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗
textView.getPaint().setFakeBoldText(true);//加粗
2.字體大小
textView.setTextSize(500);
3.字體斜體
SpannableString sp = new SpannableString( "斜體文本" ); //設置斜體
sp.setSpan( new StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 0 , tmp.length() , Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
textView.setText(sp);
『肆』 Android中在actionbar中點擊了某一個menuitem,之後就需要讓這個menuitem上的文字加粗顯示
加到我的控制項的ID,然後在代碼中進行點擊監聽應該是可以改變字體粗細的.
TextView tv = (TextView)findViewById(R.id.tv);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);
『伍』 android 如何設置中文粗體,我試了在xml文件中使用android:textStyle="bold" 可以將英文設置成粗體,但是
設置是對的,只是系統自帶的字體中文顯示粗體不明顯,實在要區別的話,可以自己附帶字體
『陸』 android 在xml的textStyle中 如何設置一個字體即是粗體又是斜體又帶有下劃線
設置字體的時候可以這樣用的
android:textStyle="bold|……"
多個選項中間可以用|分開的
『柒』 android 怎麼設置textview指定的字元加粗顯示
普通:
textview.setText("hello, 你好嗎");
加粗:
textview.setText(Html.fromHtml("hello, <b>你好嗎</b>"));
『捌』 android手機程序開發怎樣設置手機字體,比如:設置成宋體或楷體android有個功能
Android系統自帶有對字體的設置,這些設置是對字體的顯示方式的設置,比如加粗,傾斜,下劃線,字型大小等,但是對於字體本身,比如設置為楷體,隸書等沒有。Android系統只有一種默認的,如果需要修改字體,或者引用自己喜歡的字體,那麼就需要自己設置或修改。
最簡單的修改系統的字體的方法就是可以下載可以修改字體的app。網上或者手機自帶的應用中心裡去搜索吧。
『玖』 如何設置 android.support.design.widget.tablayout的選擇的文本進行加粗顯示
1.首先導入庫:
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
2. 然後就是 布局文件
<?xml version="1.0" encoding="utf-8"?>
<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=".TabLayoutActivity">
<android.support.design.widget.TabLayout
android:id="@+id/tl_tabs"
style="@style/MyCustomTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:id="@+id/vp_viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@android:color/white"/>
</LinearLayout>
3. 這里將TabLaoyut的樣式設置放入到了style文件中了,顏色神馬的就不貼了
如果在布局中使用屬性, 帶tab開頭的屬性使用"app:"前綴而不是"andorid:"前綴
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout"> <!--Tablayout 使用的樣式-->
<item name="tabMaxWidth">@dimen/tab_max_width</item> <!--TAB最大寬度-->
<item name="tabIndicatorColor">?attr/colorAccent</item> <!--TAB底部滑塊顏色-->
<item name="tabIndicatorHeight">5dp</item> <!--TAB底部滑塊高度-->
<item name="tabPaddingStart">12dp</item> <!--TAB左邊padding-->
<item name="tabPaddingEnd">12dp</item> <!--TAB右邊padding-->
<item name="tabBackground">?attr/selectableItemBackground</item> <!--TAB背景色-->
<item name="tabTextAppearance">@style/MyCustomTabTextAppearance</item> <!--TAB文字樣式-->
<item name="tabSelectedTextColor">?android:textColorPrimary</item> <!--TAB選中文字顏色-->
</style>
<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab"> <!--TAB文字樣式-->
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:textColorSecondary</item>
<item name="textAllCaps">false</item> <!--英文大寫,默認true-->
</style>
<dimen name="tab_max_width">36dp</dimen>
</resources>
4.然後就是Activity文件了
public class TabLayoutActivity extends AppCompatActivity {
private ViewPagerAdapter viewPagerAdapter;
private ViewPager viewPager;
private TabLayout tl;
private static final String POSITION = "position";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tablayout);
viewPager = (ViewPager) findViewById(R.id.vp_viewpager);
tl = (TabLayout) findViewById(R.id.tl_tabs);
}
@Override
protected void onResume() {
super.onResume();
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(viewPagerAdapter);
tl.setupWithViewPager(viewPager); //ViewPager 和 TabLayout 關聯
tl.setTabMode(TabLayout.MODE_SCROLLABLE); //用於多個TAB, Tablayout可以滾動
//更改TAB默認的文本布局,自定義TAB布局
for (int i = 0; i < tl.getTabCount(); i++) {
TabLayout.Tab tabAt = tl.getTabAt(i);
tabAt.setCustomView(viewPagerAdapter.getTabView(i));
}
viewPagerAdapter.notifyDataSetChanged();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(POSITION, tl.getSelectedTabPosition());
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
viewPager.setCurrentItem(savedInstanceState.getInt(POSITION));
}
}
5. 然後就是ViewPager的Adapter了
private class ViewPagerAdapter extends FragmentPagerAdapter {
int pageCount = 10;
private int color[] = new int[]{R.color.orange, R.color.green, R.color.red,
R.color.color_grays, R.color.color_red, R.color.color_black,
R.color.color_furvous, R.color.color_blue, R.color.color_green,R.color.color_orange
};
public ViewPagerAdapter(FragmentManager supportFragmentManager) {
super(supportFragmentManager);
}
@Override
public Fragment getItem(int position) {
return ViewPagerFragment.getInstance(position + 1, color[position]);
}
@Override
public int getCount() {
return pageCount;
}
@Override
public CharSequence getPageTitle(int position) {
// if (position == 4) {
// Drawable img = getResources().getDrawable(R.drawable.ic_one);
// img.setBounds(0, 0, img.getIntrinsicWidth(), img.getIntrinsicHeight());
// SpannableString sb = new SpannableString("Page" + (position + 1) + " ");
// ImageSpan imageSpan = new ImageSpan(img, ImageSpan.ALIGN_BASELINE);
// sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// return sb;
// }else{
// return "Page" + (position + 1);
// }
return null; //如果採用自定義TAB布局,則這里返回null就可以了
}
//引入TAB自定義布局
public View getTabView(int position) {
View view = View.inflate(TabLayoutActivity.this, R.layout.tab_item, null);
TextView tv = (TextView) view.findViewById(R.id.tv);
ImageView iv = (ImageView) view.findViewById(R.id.iv);
tv.setText("Page" + (position + 1));
if (position == 5) {
iv.setVisibility(View.VISIBLE);
} else {
iv.setVisibility(View.GONE);
}
return view;
}
}
6.然後可能重要的就是Fragment了
public class ViewPagerFragment extends BaseFragment {
public int page;
private int color;
public static final String GETPAGE = "get_page";
public static final String GETCOLOR = "get_color";
private static List<ViewPagerFragment> frags = new ArrayList<>();
private View rootView;
public static Fragment getInstance(int page, int color) {
ViewPagerFragment cacheFrag = null;
cacheFrag = getCacheFrag(page, cacheFrag);
if (cacheFrag != null){
return cacheFrag; //首先嘗試獲取緩存的Fragment
}
Bundle args = new Bundle();
args.putInt(GETPAGE, page);
args.putInt(GETCOLOR, color);
//new 一個Fragment
ViewPagerFragment pageFragment = new ViewPagerFragment();
pageFragment.setArguments(args);
frags.add(pageFragment);
return pageFragment;
}
//獲取緩存的Fragment
private static ViewPagerFragment getCacheFrag(int page, ViewPagerFragment cacheFrag) {
if (frags != null && frags.size() > 0){
for (ViewPagerFragment frag : frags){
if (frag.page == page){
cacheFrag = frag;
break;
}
}
}
return cacheFrag;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
page = getArguments().getInt(GETPAGE);
color = getArguments().getInt(GETCOLOR);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.i(this.getClass().getSimpleName(), "onCreateView");
if(rootView == null) {
rootView = inflater.inflate(R.layout.layout_fragment, container, false);
TextView tv = (TextView) rootView.findViewById(R.id.tv_fragment);
tv.setText("Page=====>" + page);
rootView.setBackgroundResource(color);
}
//緩存的rootView需要判斷是否已經被加過parent, 如果有parent需要從parent刪除,
//要不然會發生這個rootview已經有parent的錯誤。
ViewGroup parent = (ViewGroup) rootView.getParent();
if (parent != null){
parent.removeView(rootView);
}
return rootView;
}
}
『拾』 android textview字體加粗 多少
Android中字體加粗
一、在xml文件中使用android:textStyle=」bold」
二、但是不能將中文設置成粗體,將中文設置成粗體的方法是:
TextView tv = (TextView)findViewById(R.id.TextView01);
TextPaint tp = tv.getPaint();
tp.setFakeBoldText(true);