ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Is changing in res/XML view attributes possible at run time in android? Like changing the ImageView width and height.

I have ImageView and two EditText in my XML layout. In order to set these view, information is being fetched from server. based on the attributes of the information I want to change the look of layout. if image resolution is small I want it to display like |------- |--------------| |Image |__Text___| | view | Text | |____|________| if image is bigger I want to change same layout like __________________ | | | image view | |_________________ | |_____Text_________| |_____Text_________| . . . There can be some more combination using1 image and2 textView Currently I m using ListView to display the result and want to display result as dynamic template. I mean to say in list view each row may be having different layout which is not defined in res/XML. In res/XML where will be only xml file represent the list view row but I want to change this at run time in adapter, based on the size of image and text. Any Idea?

user-image
تم إضافة السؤال من قبل SHANI VISHWAKARMA , Cadence Design Systems , Cadence Design Systems
تاريخ النشر: 2013/09/20
Mohammad Malik
من قبل Mohammad Malik , Software & Website Developer , Phoenix People Technologies

int finalHeight, finalWidth;finalImageView iv =(ImageView)findViewById(R.id.scaled_image);finalTextView tv =(TextView)findViewById(R.id.size_label);ViewTreeObserver vto = iv.getViewTreeObserver(); vto.addOnPreDrawListener(newViewTreeObserver.OnPreDrawListener(){publicboolean onPreDraw(){ finalHeight = iv.getMeasuredHeight(); finalWidth = iv.getMeasuredWidth(); tv.setText("Height: "+ finalHeight +" Width: "+ finalWidth);returntrue;}});

You can then add your image scaling work from within the onPreDraw() method.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟