List of usage examples for android.widget TextView setGravity
public void setGravity(int gravity)
From source file:com.joravasal.comicagg.ComicDetailFragment.java
@SuppressLint({ "NewApi" }) @Override/* w w w. jav a2s .com*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_comic_detail, container, false); if (comicItem == null && savedInstanceState.containsKey(ARG_ITEM_ID)) { comicItem = new ComicItem(savedInstanceState.getString(ARG_ITEM_ID), savedInstanceState.getString("comicname"), savedInstanceState.getString("comicurl"), savedInstanceState.getString("unreadcount")); } int unread = Integer.parseInt(comicItem.unreadCount); if (unread == 0) { rootView.findViewById(R.id.vote_bar).setVisibility(View.GONE); } LinearLayout stripList = (LinearLayout) rootView.findViewById(R.id.strips_list); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (comicItem.id.equals(ComicStripsContent.id) && ComicStripsContent.ITEMS.size() > unread) { unread = ComicStripsContent.ITEMS.size(); } for (int i = 1; i < unread; i++) { ImageView iv = new ImageView(getActivity()); iv.setId(Integer.MAX_VALUE - i); iv.setPadding(16, 16, 16, 0); iv.setContentDescription(getString(R.string.strip_description)); iv.setAdjustViewBounds(true); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO check if there is need of opening? or always open? openFullscreenStrip(v); } }); TextView tv = new TextView(getActivity()); tv.setId(i); tv.setPadding(16, 4, 16, 4); tv.setGravity(Gravity.CENTER); stripList.addView(iv, layoutParams); stripList.addView(tv, layoutParams); } if (!comicItem.id.equals(ComicStripsContent.id)) { new GetComicsStrips(comicItem.id, unread, rootView).execute(); } else { new GetComicsStrips(comicItem.id, unread, rootView).onPostExecute(null); } if (savedInstanceState != null && savedInstanceState.containsKey(VERTICAL_SCROLLING_POSITION) && VERSION.SDK_INT >= 14) { rootView.findViewById(R.id.comic_scrollView).scrollTo(0, savedInstanceState.getInt(VERTICAL_SCROLLING_POSITION)); } return rootView; }
From source file:com.huahan.hhbaseutils.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/*from w w w.j a v a2s . co m*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); if (isSingleLine) { tab.setSingleLine(); } tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:brostore.maquillage.custom.PagerSlidingTabStrip.java
private void addCustomTextTab(final int position, String title) { LinearLayout conteneur = new LinearLayout(getContext()); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); conteneur.setOrientation(LinearLayout.HORIZONTAL); conteneur.setGravity(Gravity.CENTER); TextView tab = new TextView(getContext()); TextView tabCust = new TextView(getContext()); //tabCust.setBackgroundResource(R.drawable.live_nombre); tabCust.setGravity(Gravity.CENTER); tabCust.setTextColor(Color.WHITE); tabCust.setTypeface(tabTypeface);// w w w .j a v a 2s. c o m tabCust.setTextSize(11); tabCust.setVisibility(View.GONE); int fiveDip = Utils.convertDpToPixel(5, getResources()); tabCust.setPadding(fiveDip, 0, fiveDip, 0); tabCust.setText("0"); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); conteneur.addView(tab, param); param.leftMargin = Utils.convertDpToPixel(10, getResources()); conteneur.addView(tabCust, param); addTab(position, conteneur); }
From source file:cn.mailchat.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { //layout//from w ww.j ava 2 s . c om RelativeLayout tabLayout = new RelativeLayout(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tabLayout.setLayoutParams(layoutParams); RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textParams.addRule(RelativeLayout.CENTER_IN_PARENT); //tab TextView tab = new TextView(getContext()); tab.setId(100 + position); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tabLayout.addView(tab, textParams); //??? RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId()); viewParams.addRule(RelativeLayout.CENTER_VERTICAL); View view = new View(getContext()); ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(vParams); tabLayout.addView(view, viewParams); addTab(position, tabLayout); }
From source file:com.astuetz.PagerSlidingTabStripPlus.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//w ww .j ava2 s .com tab.setGravity(tabsGravity); tab.setSingleLine(); addTab(position, tab); }
From source file:cn.com.zzwfang.view.indicator.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setLayoutParams(getLayoutParams()); tab.setText(title);/*from ww w . j a v a 2s .com*/ tab.setFocusable(true); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); }
From source file:com.example.drugsformarinemammals.Combined_Search.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20);/*w w w . ja v a 2 s . co m*/ title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8); title.setText(messageTitle); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:com.ekuater.labelchat.ui.widget.PagerSlidingTabStrip.java
private void addIconTextTab(final int position, String title, int icon) { TextView tab = new TextView(getContext()); tab.setText(title);/*from ww w.j a va 2 s . co m*/ tab.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(icon), null, null); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);/* ww w .j av a2 s . com*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); TextView tab2 = new TextView(getContext()); tab2.setText(title); tab2.setGravity(Gravity.CENTER); tab2.setSingleLine(); addTab(position, tab, tab2); }
From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java
private void displayAlertWithMessage(String errorcode) { String errorMessage = getResources().getString(R.string.alert_message_write_error) + "\n" + getResources().getString(R.string.alert_message_write_error_code) + errorcode + "\n" + getResources().getString(R.string.alert_message_try_again); AlertDialog alert;/* ww w.j av a 2s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); TextView myMsg = new TextView(getActivity()); myMsg.setText(errorMessage); myMsg.setGravity(Gravity.CENTER_HORIZONTAL); builder.setView(myMsg); builder.setTitle(getActivity().getResources().getString(R.string.app_name)).setCancelable(false) .setPositiveButton(getActivity().getResources().getString(R.string.alert_message_exit_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert = builder.create(); alert.setCanceledOnTouchOutside(false); alert.show(); }