Here is my layout
RelativeLayout
ImageView iv1
TextView
toTheRightOf iv1
toTheEndOf
It may be helpful. I did something like that, and in my solution I am scaling down textView, but you can set shorter text.
if(textView.getWidth() > 0) {
float widthOfTheText = textView.getPaint().measureText(textView.getText());
if(widthOfTheText > textView.getWidth()) {
//exceeds, let scale it
textView.setTextScaleX((textView.getWidth()-0.1f)/widthOfTheText);
} else {
//not exceeds
}
} else {
//not layouted yet
textView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
TextView tv = (TextView) v;
float widthOfTheText = tv.getPaint().measureText(tv.getText());
tv.setTextScaleX((tv.getWidth()-0.1f)/widthOfTheText);
tv.removeOnLayoutChangeListener(this);
if(widthOfTheText > tv.getWidth()) {
//exceeds, let scale it
tv.setTextScaleX((textView.getWidth()-0.1f)/widthOfTheText);
} else {
//not exceeds
}
}
});
}