public static void MoveBottomBarButtons(int btn1Id, int btn2Id, int bottomBarId, Activity context) { var btn1 = context.FindViewById <Button>(btn1Id); var btn2 = context.FindViewById <Button>(btn2Id); var rl = context.FindViewById <RelativeLayout>(bottomBarId); rl.ViewTreeObserver.GlobalLayout += (sender, args) => { if (btn1.Width + btn2.Width > rl.Width) { btn2.SetPadding(btn2.PaddingLeft, (int)Util.convertDpToPixel(40, context), btn2.PaddingRight, btn2.PaddingBottom); } }; }
public override View GetView(int position, View convertView, ViewGroup parent) { View v = base.GetView(position, convertView, parent); TextView tv = (TextView)v.FindViewById(Android.Resource.Id.Text1); tv.SetPadding(tv.PaddingLeft, 0, tv.PaddingRight, 0); PwEntry templateEntry = this.GetItem(position); int size = (int)(Util.convertDpToPixel(Util.convertDpToPixel(20, Context), Context)); var bmp = Bitmap.CreateScaledBitmap( Util.DrawableToBitmap(App.Kp2a.GetDb() .DrawableFactory.GetIconDrawable(Context, App.Kp2a.GetDb().KpDatabase, templateEntry.IconId, PwUuid.Zero, false)), size, size, true); Drawable icon = new BitmapDrawable(bmp); if ( PreferenceManager.GetDefaultSharedPreferences(Context) .GetString("IconSetKey", Context.PackageName) == Context.PackageName) { Android.Graphics.PorterDuff.Mode mMode = Android.Graphics.PorterDuff.Mode.SrcAtop; Color color = new Color(189, 189, 189); icon.SetColorFilter(color, mMode); } //Put the image on the TextView tv.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); tv.Text = templateEntry.Strings.ReadSafe(PwDefs.TitleField); tv.SetTextSize(ComplexUnitType.Dip, 20); tv.CompoundDrawablePadding = (int)Util.convertDpToPixel(8, Context); return(v); }
public static float convertDpToPixel(float dp, Context context) { return(Util.convertDpToPixel(dp, context)); }