List of usage examples for android.widget ImageView setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:org.telegram.ui.Cells.ChatUnreadCell.java
public ChatUnreadCell(Context context) { super(context); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.chat_drawable_tint)); //setBackgroundResource(R.drawable.newmsg_divider); frameLayout.setElevation(AndroidUtilities.dp(1)); addView(frameLayout,//from www. j a v a2s . c o m LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 27, Gravity.LEFT | Gravity.TOP, 0, 8, 0, 4)); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.ic_ab_new); imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0); frameLayout.addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 10, 0)); textView = new TextView(context); textView.setPadding(0, 0, 0, AndroidUtilities.dp(1)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTextColor(Theme.CHAT_UNREAD_TEXT_COLOR); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); }
From source file:com.hbm.devices.scan.ui.android.ScanDrawer.java
ScanDrawer(final AppCompatActivity act) { drawerLayout = act.findViewById(R.id.drawer_layout); final NavigationView view = act.findViewById(R.id.navigation_view); if (view != null) { view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*w w w .jav a 2 s . c o m*/ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.drawer_settings: act.startActivity(new Intent(act.getApplicationContext(), SettingsActivity.class)); return true; case R.id.drawer_about: act.startActivity(new Intent(act.getApplicationContext(), AboutActivity.class)); return true; default: drawerLayout.closeDrawers(); return true; } } }); final View headerView = view.getHeaderView(0); if (headerView != null) { final ImageView avatar = headerView.findViewById(R.id.avatar); if (avatar != null) { avatar.setPadding(0, getStatusBarHeight(act), 0, 0); } } } }
From source file:ti.android.ble.devicemonitor.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(mResourceFragmentPager); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ImageView view = (ImageView) findViewById(android.R.id.home); view.setPadding(10, 0, 20, 10); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(mResourceIdPager); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* ww w . j ava 2 s .co m*/ public void onPageSelected(int n) { Log.d(TAG, "onPageSelected: " + n); actionBar.setSelectedNavigationItem(n); } }); // Create the adapter that will return a fragment for each section mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mSectionsPagerAdapter); }
From source file:com.moxm.frameworks.support.indicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();//from w w w .j a v a 2 s .c o m IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, 0); view.setImageResource(iconAdapter.getIconResId(i)); view.setPadding(3, 0, 3, 0); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:de.bno.snakingnumbers.tutorial.Tutorial.java
private void updateIndicator(int index) { int numberOfPages = pages.length; indicatorLayout.removeAllViews();/*from ww w. j a v a2s . c o m*/ ViewGroup.LayoutParams params = new ViewGroup.LayoutParams((int) Dimension.getDIP(20, this), (int) Dimension.getDIP(20, this)); for (int i = 0; i < numberOfPages; i++) { ImageView img = new ImageView(this); int padding = (int) Dimension.getDIP(5, this); img.setPadding(padding, padding, padding, padding); if (i == index) { img.setImageDrawable(getResources().getDrawable(R.drawable.page_indicator_active)); } else { img.setImageDrawable(getResources().getDrawable(R.drawable.page_indicator)); } indicatorLayout.addView(img, params); } }
From source file:com.airflo.FlightDetailFragment.java
/** * Method to build and add the View. It will consider preferences for * certain items, textsizes, and handle empty fields. *//*from w w w . j a v a2s.c o m*/ public void addViews() { table.setColumnShrinkable(1, true); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(OnlyContext.getContext()); float detSize = Float.valueOf(sharedPrefs.getString("detailtextsize", "20")); boolean hideEmpty = sharedPrefs.getBoolean("detailListPrefEmpty", true); for (Identi identi : FlightData.identis.getIdentis()) { String prefKey = "detailListPref" + identi.getKey(); if (sharedPrefs.getBoolean(prefKey, true)) { if (hideEmpty) { if (mItem.getFromKey(identi.getKey()) == null) continue; if (mItem.getFromKey(identi.getKey()).equals("")) continue; } if (identi.getKey().equals("tag")) { if (mItem.getFromKey(identi.getKey()).length() > 0) { LinearLayout lnn = (LinearLayout) rootView.findViewById(R.id.LinearAdditionLayout); String[] tags = mItem.getFromKey(identi.getKey()).split(";"); for (String tag : tags) { if (tag.equals("off-field")) tag = "off_field"; int resID = getResources().getIdentifier(tag, "drawable", "com.airflo"); ImageView img = new ImageView(getActivity()); img.setImageResource(resID); img.setPadding(8, 14, 8, 0); lnn.addView(img); } } } else { TableRow row = new TableRow(getActivity()); header = new TextView(getActivity()); header.setSingleLine(); header.setTextSize(detSize); header.setText(identi.getStringRep()); header.setPadding(6, 4, 10, 4); row.addView(header); cell = new TextView(getActivity()); cell.setSingleLine(false); cell.setTextSize(detSize); cell.setText(mItem.getFromKey(identi.getKey())); cell.setPadding(6, 4, 6, 4); row.addView(cell); table.addView(row); } } } }
From source file:com.bruce.study.demo.studydata.viewpage.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); LayoutInflater inflater = getLayoutInflater(); pageViews = new ArrayList<>(5); pageViews.add(inflater.inflate(R.layout.viewpager_item_01, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_02, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_03, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_04, null)); imageViews = new ImageView[pageViews.size()]; ViewGroup main = (ViewGroup) inflater.inflate(R.layout.viewpager_activity, null); ViewGroup group = (ViewGroup) main.findViewById(R.id.ll_viewgroup); ViewPager viewPager = (ViewPager) main.findViewById(R.id.vp_guide); for (int i = 0; i < pageViews.size(); i++) { ImageView imageView = new ImageView(ViewPagerActivity.this); imageView.setLayoutParams(new ViewGroup.LayoutParams(20, 20)); imageView.setPadding(20, 0, 20, 0); imageViews[i] = imageView;// w w w. jav a 2 s . c om if (i == 0) { imageViews[i].setBackgroundResource(R.drawable.viewpager_indicator_focused); } else { imageViews[i].setBackgroundResource(R.drawable.viewpage_indicator); } group.addView(imageViews[i]); } setContentView(main); viewPager.setAdapter(new MyViewPagerAdapter()); viewPager.setOnPageChangeListener(new PageChangeListener()); }
From source file:cmpe.alpha.fitwhiz.sensortag.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(mResourceFragmentPager); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ImageView view = (ImageView) findViewById(android.R.id.home); view.setPadding(10, 0, 20, 10); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(mResourceIdPager); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* ww w. ja va2s . c om*/ public void onPageSelected(int n) { // Log.d(TAG, "onPageSelected: " + n); actionBar.setSelectedNavigationItem(n); } }); // Create the adapter that will return a fragment for each section mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mSectionsPagerAdapter); }
From source file:com.jana.android.ui.view.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();//w w w. j a v a 2 s. c om IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); view.setPadding(5, 0, 5, 0); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.chillax.viewpagerindicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();//from ww w .java 2 s . c o m IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); int padding = ScreenUtil.dp2px(context, 10); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext()); view.setLayoutParams( new ViewGroup.LayoutParams(ScreenUtil.dp2px(context, 35), ScreenUtil.dp2px(context, 35))); view.setPadding(padding, padding, padding, padding); view.setScaleType(ImageView.ScaleType.FIT_XY); view.setImageResource(R.drawable.leader_icon); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }