List of usage examples for android.widget TextView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private View makeItem(final Pair<String, String> item, final int index) { TextView textView = createItemBase(); textView.setText(item.second);//from w ww . ja v a2s . c o m if ("2".equals(item.first)) { textView.setTextColor(COLOR_ITEM_ALERT); } else if ("0".equals(item.first)) { textView.setTextColor(COLOR_ITEM_NORMAL); } else { return null; } textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48))); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (actionListener != null) { actionListener.onSelected(index, item.second); dismiss(); } } }); return textView; }
From source file:com.xda.one.ui.widget.TabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set * via/*from w w w . j a va2s . c om*/ * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); // Modified for XDA One final TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.textAppearanceSmallInverse, typedValue, true); textView.setTextAppearance(getContext(), typedValue.resourceId); getContext().getTheme().resolveAttribute(android.R.attr.textColorPrimaryInverse, typedValue, true); textView.setTextColor(getResources().getColor(typedValue.resourceId)); textView.setTypeface(null, Typeface.BOLD); // Customized for app textView.setLayoutParams( new LinearLayout.LayoutParams(0, MATCH_PARENT, 1f / mViewPager.getAdapter().getCount())); textView.setSingleLine(); AutofitHelper.create(textView); // Modified for XDA One getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true); textView.setBackgroundResource(typedValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
From source file:com.clairvoyant.Components.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;// ww w. j a va 2 s . c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); LinearLayout.LayoutParams loparams = (LinearLayout.LayoutParams) tabView.getLayoutParams(); loparams.weight = 1; // loparams.height = 50; // loparams.gravity = Gravity.CENTER; tabView.setLayoutParams(loparams); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); tabTitleView.setLayoutParams( new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1f)); } if (tabView == null) { tabView = createDefaultTabView(getContext()); LinearLayout.LayoutParams loparams = (LinearLayout.LayoutParams) tabView.getLayoutParams(); loparams.weight = 1; // loparams.height = 50; // loparams.gravity = Gravity.CENTER; tabView.setLayoutParams(loparams); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.earthsea.fish.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//w ww . j a va2 s .c o m */ protected TextView createDefaultTabView(Context context) { // String activity = context.toString(); // // Log.v("tab_context",activity); // TextView textView = new TextView(context); // // if (activity.contains("SingleReport")) { // textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); // } // Instead of messing with layout params maybe we should crank up the padding when we know the // number of tab items will be low but we don't want them to be crammed into the view width textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); }*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(40, padding, 40, padding); return textView; }
From source file:fr.cph.stock.android.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Account Activity onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.account_activity); Bundle b = getIntent().getExtras();//from w w w . j av a 2 s .com portfolio = b.getParcelable("portfolio"); errorView = (TextView) findViewById(R.id.errorMessage); totalValueView = (TextView) findViewById(R.id.totalValue); totalGainView = (TextView) findViewById(R.id.totalGain); totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue); lastUpateView = (TextView) findViewById(R.id.lastUpdate); liquidityView = (TextView) findViewById(R.id.liquidity); yieldYearView = (TextView) findViewById(R.id.yieldYear); shareValueView = (TextView) findViewById(R.id.shareValue); gainView = (TextView) findViewById(R.id.gain2); perfView = (TextView) findViewById(R.id.perf); yieldView = (TextView) findViewById(R.id.yieldPerf); taxesView = (TextView) findViewById(R.id.taxes); RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout); TextView recent = new TextView(getApplicationContext()); textViews = new ArrayList<TextView>(); int id = 1; int nameID = 100; int viewId1 = 500; int currencyId = 1000; for (int i = 0; i < portfolio.getAccounts().size(); i++) { Account account = portfolio.getAccounts().get(i); TextView currentAccountNameTextView = new TextView(getApplicationContext()); currentAccountNameTextView.setText(account.getName()); currentAccountNameTextView.setTextColor(Color.GRAY); currentAccountNameTextView.setId(nameID); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); currentAccountNameTextView.setLayoutParams(params); accLayout.addView(currentAccountNameTextView, params); textViews.add(currentAccountNameTextView); View viewPoint1 = new View(getApplicationContext()); viewPoint1.setId(viewId1); viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, nameID); params.addRule(RelativeLayout.LEFT_OF, currencyId); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint1.setLayoutParams(params); accLayout.addView(viewPoint1, params); TextView currentCurrencyTextView = new TextView(getApplicationContext()); currentCurrencyTextView.setText(account.getCurrency()); currentCurrencyTextView.setTextColor(Color.GRAY); currentCurrencyTextView.setId(currencyId); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } currentCurrencyTextView.setLayoutParams(params); accLayout.addView(currentCurrencyTextView, params); textViews.add(currentCurrencyTextView); View viewPoint2 = new View(getApplicationContext()); viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, currencyId); params.addRule(RelativeLayout.LEFT_OF, id); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint2.setLayoutParams(params); accLayout.addView(viewPoint2, params); TextView currentTextView = new TextView(getApplicationContext()); currentTextView.setText(account.getLiquidity()); currentTextView.setTextColor(Color.GRAY); currentTextView.setId(id); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); currentTextView.setLayoutParams(params); recent = currentTextView; accLayout.addView(currentTextView, params); textViews.add(currentTextView); id++; nameID++; viewId1++; currencyId++; } buildUi(false); // Set context EasyTracker.getInstance().setContext(getApplicationContext()); // Instantiate the Tracker tracker = EasyTracker.getTracker(); }
From source file:com.ltf.mytoolslibrary.viewbase.viewPagerGuidanceActivityMyLib.SpringIndicator.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void addTabItems() { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(20, 20); tabs = new ArrayList<>(); layoutParams.setMargins(15, 0, 15, 0); for (int i = 0; i < viewPager.getAdapter().getCount(); i++) { TextView textView = new TextView(getContext()); if (viewPager.getAdapter().getPageTitle(i) != null) { textView.setText(viewPager.getAdapter().getPageTitle(i)); }//www .j av a 2 s . com textView.setGravity(Gravity.CENTER); // textView.setBackground(getResources().getDrawable(R.drawable.steward_msg_red)); textView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.circle_orange)); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); textView.setTextColor(getResources().getColor(textColorId)); if (textBgResId != 0) { textView.setBackgroundResource(textBgResId); } textView.setLayoutParams(layoutParams); final int position = i; textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (tabClickListener == null || tabClickListener.onTabClick(position)) { viewPager.setCurrentItem(position); } } }); tabs.add(textView); tabContainer.addView(textView); } }
From source file:com.nicolls.ablum.activity.BucketHomeFragmentActivity.java
@SuppressLint("ResourceAsColor") @Override//from w w w. jav a2s . c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); mediaType = getIntent().getStringExtra("mediaType"); List<String> pathList = getIntent().getStringArrayListExtra("pathList"); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); headerBarDone.setVisibility(View.INVISIBLE); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); mTabHost.addTab( mTabHost.newTabSpec("tab1").setIndicator(getResources().getString(R.string.images_tab) + " "), BucketImageFragment.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab2").setIndicator(getResources().getString(R.string.videos_tab) + " "), BucketVideoFragment.class, null); mTabHost.getTabWidget().setBackgroundColor(getResources().getColor(R.color.tabs_color)); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { View childView = mTabHost.getTabWidget().getChildAt(i); TextView textView = (TextView) childView.findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { // Toast.makeText(getApplicationContext(),tabId,Toast.LENGTH_LONG).show(); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); BucketImageFragment imageFragment = (BucketImageFragment) fragmentManager.findFragmentByTag("tab1"); BucketVideoFragment videoFragment = (BucketVideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); headerBarCamera.setBackgroundResource(R.drawable.selector_camera_button); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment == null) { BucketImageFragment newImageFragment = new BucketImageFragment(); fragmentTransaction.add(R.id.realTabcontent, newImageFragment, "tab1"); } else { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); headerBarCamera.setBackgroundResource(R.drawable.selector_video_button); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment == null) { final BucketVideoFragment newVideoFragment = new BucketVideoFragment(); fragmentTransaction.add(R.id.realTabcontent, newVideoFragment, "tab2"); } else { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); if (TextUtils.equals(mediaType, MediaChooserConstants.TYPE_PHOTO)) {//? mTabHost.setCurrentTab(0); headerBarTitle.setText(getResources().getString(R.string.image)); headerBarCamera.setTag(getResources().getString(R.string.image)); headerBarCamera.setBackgroundResource(R.drawable.selector_camera_button); } else { mTabHost.setCurrentTab(1); headerBarTitle.setText(getResources().getString(R.string.video)); headerBarCamera.setTag(getResources().getString(R.string.video)); headerBarCamera.setBackgroundResource(R.drawable.selector_video_button); } }
From source file:edu.csun.campusharvest.common.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*w ww .ja v a 2 s . c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextSize(14f); tabTitleView.setLayoutParams( new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); tabTitleView.setTextColor(getResources().getColorStateList(R.color.white)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.example.de.taomi2.mediachooser.activity.BucketHomeFragmentActivity.java
@SuppressLint("ResourceAsColor") @Override//from w w w . ja v a 2s . co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); headerBarTitle.setText(getResources().getString(R.string.video)); headerBarCamera.setBackgroundResource(R.drawable.ic_video_unselect_from_media_chooser_header_bar); headerBarCamera.setTag(getResources().getString(R.string.video)); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); } mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), BucketVideoFragment.class, null); } if (MediaChooserConstants.showImage) { mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), BucketImageFragment.class, null); } mTabHost.getTabWidget().setBackgroundColor(getResources().getColor(R.color.tabs_color)); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { View childView = mTabHost.getTabWidget().getChildAt(i); TextView textView = (TextView) childView.findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); BucketImageFragment imageFragment = (BucketImageFragment) fragmentManager.findFragmentByTag("tab1"); BucketVideoFragment videoFragment = (BucketVideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); headerBarCamera.setBackgroundResource(R.drawable.selector_camera_button); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment == null) { BucketImageFragment newImageFragment = new BucketImageFragment(); fragmentTransaction.add(R.id.realTabcontent, newImageFragment, "tab1"); } else { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); headerBarCamera.setBackgroundResource(R.drawable.selector_video_button); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment == null) { final BucketVideoFragment newVideoFragment = new BucketVideoFragment(); fragmentTransaction.add(R.id.realTabcontent, newVideoFragment, "tab2"); } else { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:gov.wa.wsdot.android.wsdot.ui.tollrates.I405TollRatesFragment.java
/** * Adds a toll rate accuracy disclaimer to the bottom of the view * @param root//from w ww. j a v a2 s.c o m */ private void addDisclaimerView(ViewGroup root) { FrameLayout frame = root.findViewById(R.id.list_container); TextView textView = new TextView(getContext()); textView.setBackgroundColor(getResources().getColor(R.color.alerts)); textView.setText( "Estimated toll rates provided as a courtesy. Youll always pay the toll you see on actual road signs when you enter."); textView.setPadding(15, 20, 15, 15); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; textView.setLayoutParams(params); frame.addView(textView); }