I have to align horizontally in the center|bottom of the activity two imageviews and I have to resize the imageviews in a screen width percentage (ex. 10% of screen width).
If I don't apply the resize, I have two imageviews in the center|bottom, but too big;
if I apply the resize, I have only the first in the center; the other one is disappeared!
I've tried to use Linearlayouts (orientation = horizontal) and Tablelayout...no results!
This is my activity XML when I'used the Tablelayout:
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="48dp" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imgLogoCosoft"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_cosoft" />
<ImageView
android:id="#+id/imgLogoFeelife"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_feelife" />
</TableRow>
</TableLayout>
This is my activity XML when I've used the Linearlayout:
<LinearLayout
android:id="#+id/linearSplash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom"
android:paddingTop="20dp"
android:layout_alignParentBottom="true">
<ImageView
android:id="#+id/imgLogoCosoft"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_cosoft" />
<ImageView
android:id="#+id/imgLogoFeelife"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_feelife" />
</LinearLayout>
This is the Java code when I've used the Linearlayout:
int DisplayWidth = Funzioni.ScreenWidth (SplashScreen.this);
int DisplayHeight = Funzioni.ScreenHeight(SplashScreen.this);
imgLogoCosoft = (ImageView)findViewById(R.id.imgLogoCosoft);
LayoutParams params_imgLogoCosoft = new LayoutParams(DisplayWidth,(DisplayHeight/100)*10);
imgLogoCosoft.setLayoutParams(params_imgLogoCosoft);
imgLogoFeelife = (ImageView)findViewById(R.id.imgLogoFeelife);
LayoutParams params_imgLogoFeelife = new LayoutParams(DisplayWidth,(DisplayHeight/100)*10);
imgLogoFeelife.setLayoutParams(params_imgLogoFeelife);
Suggestions?
Thanks in advance!
Ok, I'll answer to myself.
For the tho images to place and resize at the bottom of the activity, instead of
LayoutParams params_imgLogoCosoft = new LayoutParams(DisplayWidth,(DisplayHeight/100)*10);
imgLogoCosoft.setLayoutParams(params_imgLogoCosoft);
I've used
imgLogoCosoft.getLayoutParams().width = DisplayWidth/10;
This is the XML of the Activity:
<ImageView
android:id="#+id/imgSfondoSplash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="#drawable/back_splash" />
<ProgressBar
android:id="#+id/pgbSplash"
style="?android:attr/progressBarStyleLarge"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_below="#+id/imgSfondoSplash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"">
<ImageView
android:id="#+id/imgLogoCosoft"
android:layout_alignParentBottom="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_cosoft" />
<ImageView
android:id="#+id/imgLogoFeelife"
android:layout_alignParentBottom="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="#drawable/logo_feelife" />
</RelativeLayout>
And this is the code of the activity:
imgSfondoSplash = (ImageView)findViewById(R.id.imgSfondoSplash);
RelativeLayout.LayoutParams params_imgSfondoSplash = new RelativeLayout.LayoutParams(DisplayWidth,(DisplayHeight/100)*90);
imgSfondoSplash.setLayoutParams(params_imgSfondoSplash);
imgLogoCosoft = (ImageView)findViewById(R.id.imgLogoCosoft);
RelativeLayout.LayoutParams lp_imgLogoCosoft=new RelativeLayout.LayoutParams((DisplayWidth / 10), (DisplayWidth / 10));
lp_imgLogoCosoft.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
imgLogoCosoft.setLayoutParams(lp_imgLogoCosoft);
imgLogoFeelife = (ImageView)findViewById(R.id.imgLogoFeelife);
RelativeLayout.LayoutParams lp_imgLogoFeelife=new RelativeLayout.LayoutParams((DisplayWidth / 10), (DisplayWidth / 10));
lp_imgLogoFeelife.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
lp_imgLogoFeelife.addRule(RelativeLayout.RIGHT_OF, R.id.imgLogoCosoft);
imgLogoFeelife.setLayoutParams(lp_imgLogoFeelife);
I hope this could be useful for other developers.
Related
I have had a big trouble since several hours;
I have a recyclerview with several elements in each item. For one of them (lv_container), I can decrease its height but not increase it.
See the screenshot:
the xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/dashboard_part_medical_file_locked_title"
android:textSize="18sp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/row_dashboard_color"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="#+id/dashboard_part_image"
android:layout_width="80dp"
android:layout_height="95dp"
android:layout_alignParentEnd="true"
android:paddingBottom="20dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="20dp"
android:src="#drawable/dossier_medical" />
<RelativeLayout
android:id="#+id/lv_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/dashboard_part_image"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/dashboard_part_image"
android:layout_toStartOf="#+id/dashboard_part_image"
android:background="#android:color/white"
android:padding="10dp">
<ImageView
android:id="#+id/sup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_sup" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_toStartOf="#id/sup"
android:text="#string/dashboard_part_medical_file_inside" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
and the code of the viewholder
DisplayMetrics metrics = pContext.getResources().getDisplayMetrics();
RelativeLayout.LayoutParams lvContainerParams = (RelativeLayout.LayoutParams) lvContainer.getLayoutParams();
lvContainerParams.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
lvContainerParams.height = (int) (40 * metrics.density + 20 * metrics.density);
lvContainer.setLayoutParams(lvContainerParams);
ViewGroup.LayoutParams mainContainerParams = mainContainer.getLayoutParams();
mainContainerParams.height = (int) (lvContainerParams.height + 20 * metrics.density);
mainContainer.setLayoutParams(mainContainerParams);
ViewGroup.LayoutParams params = itemView.getLayoutParams();
params.height = (int) (mainContainerParams.height + 50 * metrics.density);
itemView.setLayoutParams(params);
When I change the height of lvContainer (the white container), the height of mainContainer is well modified (as you can see with the blue container), but the white container always remains fixed. However, in debug, heights are well calculated.
I tried to call lvContainer.invalidate() and/or lvContainer.requestLayout(), but nothing changed.
What's the error? Why the height of item and mainContainer can be easily modified, but not this of lvContainer?
I need your help
Thanks
Try removing this line
android:layout_alignBottom="#+id/dashboard_part_image"
I have a compound view. I have a ImageButton that I want to be able to drag left and right. I can drag it left and up of it's original position and it looks fine. If I ever go right or below it's original position, the button disappears. I have enabled the developer option to draw view bounds. I see that the left and top bounds expand and shrink as I move the ImageButton. The right and bottom do not.
Here it is moving left and up with no problems
Here it is moving beyond it's original bounds to the right, you can see it disappearing as it crosses the right line.
I have tried setting new layout params on the button, but saw no change in position. So I'm using setLeft() and setBottom(). Why is my button disappearing?
#OnTouch(R.id.silence_snooze_choice_button)
public boolean choiceButtonClicked(View v, MotionEvent event){
//LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) choiceButton.getLayoutParams();
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
int x_cord = (int)event.getRawX();
int y_cord = (int)event.getRawY();
DisplayMetrics metrics = getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
Log.i(TAG, String.format("%d,%d", x_cord, y_cord));
//this didn't work.
//layoutParams.leftMargin = x_cord -25;
//layoutParams.topMargin = y_cord - 75;
//choiceButton.setLayoutParams(layoutParams);
choiceButton.setLeft(x_cord);
choiceButton.setBottom(y_cord);
break;
default:
break;
}
return true;
}
Here is my layout for my view up top. CircleDragSelector is the name of the compound view.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="180dp"
android:background="#color/primary"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_margin="16dp"
android:layout_centerVertical="true"
android:src="#drawable/abc_ic_menu_paste_mtrl_am_alpha"
/>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:layout_centerVertical="true"
android:src="#drawable/ic_action_share"
/>
<ImageButton
android:id="#+id/silence_snooze_choice_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_play_circle_outline"
/>
</RelativeLayout>
Here is the parent layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<SurfaceView
android:id="#+id/surface_view_camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<View
android:id="#+id/view_transparent_overlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:alpha="0.85"/>
<TextView
android:id="#+id/alarm_screen_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp"
android:textSize="36sp"
android:textColor="#color/accent_material_dark"
android:text="Alarm name" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/alarm_screen_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/alarm_screen_name"
android:layout_marginTop="28dp"
android:layout_centerHorizontal="true"
android:text="00 : 00"
android:textSize="52dp"
android:textColor="#color/accent_material_dark"
/>
<ImageButton
android:id="#+id/alarm_screen_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
android:src="#drawable/ic_cancel_black_48dp"
android:background="#null"
android:text="Dismiss"
android:textSize="28dp" />
<com.example.tyler.rollout.views.CircleDragSelector
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</com.example.tyler.rollout.views.CircleDragSelector>
</RelativeLayout>
By default, layouts clip their children, meaning things like negative margins are hidden by default.
Putting
<RelativeLayout
...
clipChildren="false">
on the parent layout should fix this.
I have an XML Layout with imageButton and I want add "later" some imageButtons programmatically. Unfortunetly the added buttons cover the XML button. How can I use the zindex? Zindex attribute doesn't exist. I want #+id/btn_surface upper.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:fillViewport="false">
<RelativeLayout
android:id="#+id/rLayoutss"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="5000px"
android:layout_height="fill_parent"
android:background="#drawable/repeattile"
tools:context="com.some.asc.somesystems.SomeActivity"
>
<ImageView
android:layout_height="fill_parent"
android:layout_width="5000px"
android:id="#+id/iw_pcover"
android:background="#drawable/repeatovertile"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<RelativeLayout
android:layout_width="800px"
android:layout_height="480px"
android:background="#color/gray"
android:visibility="visible"
android:id="#+id/rl_all_hud"
>
<LinearLayout
android:layout_width="105px"
android:layout_height="106px"
android:visibility="visible"
android:id="#+id/ll_surface"
android:orientation="vertical">
<ImageButton
android:layout_width="106px"
android:layout_height="105px"
android:id="#+id/btn_surface"
android:background="#drawable/terr_button_surface"
/>
<TextView
android:layout_width="94px"
android:layout_height="105px"
android:id="#+id/tv_surface"
android:text="Surface"
android:layout_marginLeft="6dp"
android:layout_marginTop="-26dp"
android:textColor="#android:color/white"
android:textSize="14px"
android:shadowColor="#android:color/black"
android:shadowDx="2"
android:shadowDy="2"
android:shadowRadius="2"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</HorizontalScrollView>
</ScrollView>
Add imageButton:
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rLayoutss);
ImageButton largeIcon = new ImageButton(context);
largeIcon.setImageResource(
getResources().getIdentifier(PObject.getString("imgsrc"), "drawable", getPackageName())
);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(80,80);
lp.leftMargin = 100;
lp.topMargin = 100;
largeIcon.setLayoutParams(lp);
largeIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
largeIcon.setBackgroundColor(Color.TRANSPARENT);
relativeLayout.addView(largeIcon);
Thanks for any help
When you add your childView, largeIcon in this case you want to use the ViewGroup.addView(View view, int index) method. This will allow you to specify which order you want your views to appear in.
For your case, you might want to try: relativeLayout.addView(largeIcon, 0);
I'm trying to align the seekbar to the top of a view, but i can't center it with the thumb.
Is there some kind of "alignCenter" with the RelativeLayout children.
Here's a sample of my xml code :
<RelativeLayout
android:id="#+id/rl_fragment_audio_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/black_transparent"
android:padding="5dp"
android:visibility="gone" >
<TextView
android:id="#+id/tv_fragment_audio_begin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="#color/white" />
<TextView
android:id="#+id/tv_fragment_audio_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:textColor="#color/white" />
<Button
android:id="#+id/btn_fragment_audio_play"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"
android:background="#drawable/btn_play"
android:visibility="gone" />
</RelativeLayout>
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_above="#id/rl_fragment_audio_player" />
For example, Google Play Music does it.
As you said the height of your seekbar might vary, unless you specify it different. Here is how you can make sure it fits all, always.
android:layout_above="#id/rl_fragment_audio_player"
is setting your seekbar bottom above rl_fragment_audio_player top. There is no direct method to specify centerAlignWith but I would remove the space it occupies within it's parent. To know the height of the seekbar you must wait until the global layout has changed. This code should be placed inside your onCreateView
sb = (SeekBar) rootView.findViewById(R.id.sb_fragment_audio);
sb.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener(){
#Override
public void onGlobalLayout() {
sb.getViewTreeObserver().removeOnGlobalLayoutListener(this);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sb.getLayoutParams();
params.setMargins(0, - sb.getHeight() / 2, 0, - sb.getHeight() / 2);
sb.setLayoutParams(params);
// I suggest you set the seekbar visible after this so that it won't jump
}
});
The last view in the xml will be in the front. Therefore make sure your seekbar is added after the the other views. Like this
<RelativeLayout
android:id="#+id/rl_fragment_audio_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
// your bottom panel
</RelativeLayout>
<View
android:id="#+id/image_above"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/rl_fragment_audio_player" />
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/image_above" />
Have you tried adding a negative margin to the seekbar?
<SeekBar
android:id="#+id/sb_fragment_audio"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginBottom="-15dp"
android:layout_above="#id/rl_fragment_audio_player" />
I have the following ListView-item:
Currently everything works as intended and is placed where it should, except for the width of the TextView (2).
Since I use a RelativeLayout with some wrap_contents, I use a onGlobalLayoutListener so I can access the MeasuredWidths and Heights the moment the View is done loading and rendering. With the TextView2 however I get some weird results when I debug.
The first time onGlobalLayout is called, measuredWidth of the TextView2 is what it should be (375 px). The second time however, it's 48 px (same as the Height) and when I look at the fields of the TextView2 it says: mMeasuredHeight: 375; mMeasuredWidth: 48 :S
My layout is at the bottom of this post. My onGlobalLayoutListener is:
if(view.getViewTreeObserver().isAlive()){
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
// This will be called once the layout is finished, prior to displaying it
// So we can change some widths and heights based on other View-Elements that are filled now
// (We couldn't do this in the XML itself since they weren't filled yet and we didn't knew the sizes yet.)
#Override
public void onGlobalLayout() {
if(holder != null){
...
// Change the height of the ProductName-TextView to match the Image and leave the width as is
int height = h.imageView.getMeasuredHeight();
int width = h.tvName.getMeasuredWidth();
* h.tvName.setLayoutParams(new RelativeLayout.LayoutParams(h.imageView.getMeasuredHeight(), h.tvName.getMeasuredWidth()));
...
}
// Since we don't want onGlobalLayout to continue forever, we remove the Listener here again.
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
The * is a breakpoint. The first time width is 48 and height is 375. The second time width is 48 and height is 48, and if I look at the mMeasuredHeight and mMeasuredWidth fields in my holder.textView2, they are h=375 and w=48 :S
Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/item_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:id="#+id/left_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentLeft="true"
android:layout_marginTop="#dimen/default_margin"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#layout/transparent_background"
android:contentDescription="#string/checkbox_content_description"
android:src="#drawable/checkbox_unchecked" />
<Space
android:id="#+id/filler_space_image"
android:layout_width="1dp"
android:layout_height="1dp"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="#+id/tv_product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/left_ll"
android:layout_toLeftOf="#+id/right_ll"
android:ellipsize="end"
android:singleLine="true"
android:gravity="center_vertical"
android:layout_marginTop="#dimen/default_margin"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin" />
<EditText
android:id="#+id/et_result_amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tv_product_name"
android:layout_toRightOf="#id/left_ll"
android:inputType="number"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin"
android:visibility="gone" />
<AutoCompleteTextView
android:id="#+id/actv_result_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/right_ll"
android:layout_toRightOf="#id/et_result_amount"
android:layout_below="#+id/tv_product_name"
android:ellipsize="end"
android:inputType="text"
android:singleLine="true"
android:visibility="gone" />
<TextView
android:id="#+id/tv_tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_result_amount"
android:layout_toRightOf="#id/left_ll"
android:text="#string/tags"
android:gravity="center"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin"
android:visibility="gone" />
<Spinner
android:id="#+id/sp_tags"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/actv_result_name"
android:layout_toRightOf="#id/tv_tags"
android:layout_toLeftOf="#id/right_ll"
android:layout_marginLeft="#dimen/default_margin"
android:layout_marginBottom="#dimen/default_margin"
android:visibility="gone" />
<LinearLayout
android:id="#id/right_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical"
android:layout_margin="#dimen/default_margin">
<TextView
android:id="#+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical" />
<Space
android:id="#+id/filler_space_price"
android:layout_width="1dp"
android:layout_height="1dp"
android:visibility="gone" />
<ImageButton
android:id="#+id/btn_tags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#android:drawable/ic_menu_manage"
android:contentDescription="#string/button_tags_content_description"
android:background="#layout/transparent_background"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
Ok, it was (after I figured it out) pretty obvious.. Instead of
h.tvName.setLayoutParams(new RelativeLayout.LayoutParams(
h.imageView.getMeasuredHeight(), h.tvName.getMeasuredWidth()));
I now use
h.tvName.setLayoutParams(new RelativeLayout.LayoutParams(
h.tvName.getMeasuredWidth(), hh.imageView.getMeasuredHeight()));
Difference you ask? I used LayoutParams(height, width) instead of LayoutParams(width, height)...