I have a layout like this one:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#272727"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/BtnSlide"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@null"
android:src="@drawable/lin" />
<TextView
android:id="@+id/textView1"
android:layout_width="275dp"
android:layout_height="50dp"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingRight="100dp"
android:text="HEADER"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="2.2dp"
android:src="@drawable/logo" />
The ImageView is placed to the right of the screen. But I’m facing an issue, the ImageView increases and decreases in height and width depending on the length of the TextView, how can I make this work properly, without the ImageView changing size?
The problem here is that your
ImageViewmatches the size of your parent, that is yourLinearLayout(with id tabBar).That
LinearLayoutwraps the content on his height, so, it sums all “heights” of his contents. TheLinearLayoutwill take the height ofTextView+ the height of theImageButton. Then, theImageViewwill match that height.A solution depends on what you are trying to do, but you can try to:
ImageViewLinearLayoutand align all your views depending on each other